Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

After upgrading to Expo SDK 36, expo-cli crashes with "TypeError: chunk.msg.match is not a function" #1363

Closed
kevgrig opened this issue Dec 15, 2019 · 3 comments
Labels

Comments

@kevgrig
Copy link
Contributor

kevgrig commented Dec 15, 2019

Description

After upgrading to Expo SDK 36, I'm always getting the following error immediately after launching in my emulator. I never received it before. Issue #519 is similar but expo start --clear didn't help.

Observed Behavior

/@expo/[email protected]/src/logs/PackagerLogsStream.ts:493
    if (chunk.msg.match(/\(node:.\d*\)/)) {
                  ^
TypeError: chunk.msg.match is not a function
    at PackagerLogsStream.chunk [as _cleanUpNodeErrors] (/@expo/[email protected]/src/logs/PackagerLogsStream.ts:493:19)
    at Object.write (/@expo/[email protected]/src/logs/PackagerLogsStream.ts:211:24)
    at Logger._emit (/usr/lib/node_modules/expo-cli/node_modules/@expo/bunyan/lib/bunyan.js:928:22)
    at Logger.info (/usr/lib/node_modules/expo-cli/node_modules/@expo/bunyan/lib/bunyan.js:1053:24)
    at Object.logInfo (/@expo/[email protected]/src/project/ProjectUtils.ts:92:27)
    at _logPackagerOutput (/@expo/[email protected]/src/Project.ts:1573:18)
    at Stream.packagerProcess.stdout.pipe.on.data (/@expo/[email protected]/src/Project.ts:1797:7)
    at Stream.emit (events.js:198:13)
    at drain (/usr/lib/node_modules/expo-cli/node_modules/through/index.js:36:16)
    at Stream.stream.queue.stream.push (/usr/lib/node_modules/expo-cli/node_modules/through/index.js:45:5)

Environment

$ expo diagnostics

  Expo CLI 3.11.1 environment info:
    System:
      OS: Linux 5.3 Fedora 30 (Workstation Edition) 30 (Workstation Edition)
      Shell: 5.0.7 - /bin/bash
    Binaries:
      Node: 10.16.3 - /usr/bin/node
      Yarn: 1.19.2 - /usr/bin/yarn
      npm: 6.9.0 - /usr/bin/npm
    npmPackages:
      expo: ^36.0.0 => 36.0.0 
      react: 16.9.0 => 16.9.0 
      react-native: https://github.com/expo/react-native/archive/sdk-36.0.0.tar.gz => 0.61.4 
      react-navigation: ^3.13.0 => 3.13.0 
    npmGlobalPackages:
      expo-cli: 3.11.1
  • Phone/emulator/simulator platform, model and version: Android Emulator, Pixel 3a API 28

Reproducible Demo

I will try to work on this but the current code is private.

@kevgrig kevgrig changed the title After upgrading to Expo SDK 36, "TypeError: chunk.msg.match is not a function" After upgrading to Expo SDK 36, expo-cli crashes with "TypeError: chunk.msg.match is not a function" Dec 15, 2019
@kevgrig
Copy link
Contributor Author

kevgrig commented Dec 16, 2019

I'm exploring the source code and while I'm not sure how to modify the frames that are at /@expo/[...], I found in the third frame from the top (/usr/lib/node_modules/expo-cli/node_modules/@expo/bunyan/lib/bunyan.js) that there is the following line which I commented out:

//var xxx = function xxx() {};  // comment out to turn on debug logging

However, the log entries leading up to the failure just seem like they're logging some application JSON data and nothing particularly special:

XXX: writing log rec "          33" to "raw" stream (30 <= 30): {"name":"expo","hostname":"x270","pid":8503,"type":"project","project":"[...]","level":30,"tag":"metro","msg":"          33","time":"2019-12-16T06:07:01.496Z","id":"46815f80-1fca-11ea-a91c-2d452ab10d3b","v":0}

/@expo/[email protected]/src/logs/PackagerLogsStream.ts:493
    if (chunk.msg.match(/\(node:.\d*\)/)) {
                  ^
TypeError: chunk.msg.match is not a function
[...]

@kevgrig
Copy link
Contributor Author

kevgrig commented Dec 16, 2019

Looking at PackagerLogsStream.ts:211, a few lines after the failing call, there is a check for typeof chunk.msg === 'string', whereas the failing function (PackagerLogsStream.ts:488) seems to presume that if the chunk isn't of type object, then it must be a string. So, I'm just guessing, but perhaps the fix is:

$ git diff
diff --git a/packages/xdl/src/logs/PackagerLogsStream.ts b/packages/xdl/src/logs/PackagerLogsStream.ts
index 1df4d132..729f1f1a 100644
--- a/packages/xdl/src/logs/PackagerLogsStream.ts
+++ b/packages/xdl/src/logs/PackagerLogsStream.ts
@@ -490,7 +490,7 @@ export default class PackagerLogsStream {
       return chunk;
     }
 
-    if (chunk.msg.match(/\(node:.\d*\)/)) {
+    if (typeof chunk.msg === 'string' && chunk.msg.match(/\(node:.\d*\)/)) {
       // Example: (node:13817) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): SyntaxError: SyntaxError /Users/brent/universe/apps/new-project-template/main.js: Unexpected token (10:6)
       // The first part of this is totally useless, so let's remove it.
       if (chunk.msg.match(/UnhandledPromiseRejectionWarning/)) {

So I think the basic question is: how do we build a debug version of the /@expo/xdl code? I'm using a managed workflow.

@kevgrig
Copy link
Contributor Author

kevgrig commented Dec 18, 2019

Resolved after upgrading expo-cli to 3.11.2 and starting with expo start -c.

@kevgrig kevgrig closed this as completed Dec 18, 2019
@lock lock bot added the outdated label Jun 24, 2020
@lock lock bot locked and limited conversation to collaborators Jun 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant