Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'run' of undefined #1319

Closed
natew opened this issue May 8, 2018 · 28 comments
Closed

Cannot read property 'run' of undefined #1319

natew opened this issue May 8, 2018 · 28 comments
Labels

Comments

@natew
Copy link

natew commented May 8, 2018

🐛 bug report

🚨  Cannot read property 'run' of undefined
    at /Users/nw/projects/motion/orbit/node_modules/parcel-bundler/lib/workerfarm/child.js:68:45
    at Generator.next (<anonymous>)
    at step (/Users/nw/projects/motion/orbit/node_modules/parcel-bundler/lib/workerfarm/child.js:3:191)
    at /Users/nw/projects/motion/orbit/node_modules/parcel-bundler/lib/workerfarm/child.js:3:437
    at new Promise (<anonymous>)
    at /Users/nw/projects/motion/orbit/node_modules/parcel-bundler/lib/workerfarm/child.js:3:99
    at Child.handleRequest (/Users/nw/projects/motion/orbit/node_modules/parcel-bundler/lib/workerfarm/child.js:75:7)
    at Child.messageListener (/Users/nw/projects/motion/orbit/node_modules/parcel-bundler/lib/workerfarm/child.js:36:19)
    at process.emit (events.js:185:15)
    at emit (internal/child_process.js:783:12)

🤔 Expected Behavior

This is on a small site I have working with 1.6.2, but 1.8.x seems to break. Mostly just would be helpful if there was more clear error messaging here so I could debug without binary searching.

🌍 Your Environment

Software Version(s)
Parcel 1.8.2
Node 9
Operating System high sierra
@DeMoorJasper
Copy link
Member

Are you using any plugin?

It seems like the worker init message doesn't get send for that worker. Would like to debug this but i'm afraid this will be system specific. Anyway a small repro repo would maybe be helpfull

@natew
Copy link
Author

natew commented May 8, 2018

Am using this plugin actually: https://github.com/albinotonnina/parcel-plugin-inlinesvg

Is there any way these error messages could be more helpful? I'm hesitant to spend time swapping out versions and re-trying when waiting for helpful error messages may just make it clear.

@DeMoorJasper
Copy link
Member

Does it happen without the plugin?
Not sure if error messages can be more clear as they are kind of already optimal (in this case)

@natew
Copy link
Author

natew commented May 8, 2018

Ah well it doesn't say any file or plugin that it's breaking on, it seems like an internal error more than external, for example if it's with that plugin would be nice if it said the plugin name somewhere.

Perhaps it's impossible in this area to do that?

@DeMoorJasper
Copy link
Member

I guess it's possible not sure how though the workerfarm shouldn't be influenced by plugins, but apparently is, pretty strange.

Let me know if removing the plugin fixes your issue

@luke-robertson
Copy link

luke-robertson commented May 10, 2018

getting same issue trying to deploy to pipelines:

🚨  Cannot read property 'run' of undefined
    at Child.handleRequest (/opt/atlassian/pipelines/agent/build/node_modules/parcel-bundler/src/workerfarm/child.js:57:42)
    at Child.messageListener (/opt/atlassian/pipelines/agent/build/node_modules/parcel-bundler/src/workerfarm/child.js:32:19)
    at emitTwo (events.js:111:20)
    at process.emit (events.js:192:7)
    at process.nextTick (internal/child_process.js:757:12)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

@DeMoorJasper
Copy link
Member

@DesignAlchemy are you using any plugins?

@luke-robertson
Copy link

@DeMoorJasper

"parcel-plugin-eslint": "^1.0.4",

thats it

@DeMoorJasper
Copy link
Member

DeMoorJasper commented May 10, 2018

@DesignAlchemy that's probably why it's failing, this line shouldn't be used inside a plugin, as it might cause unwanted side-effects and is considered a private module/file within parcel and is being updated without keeping in mind semantic versioning:
https://github.com/BoltDoggy/parcel-plugin-eslint/blob/7a0947bdec7d4552a68ce3a3bbcba339040a2db2/src/EslintAsset.js#L5

const JSAsset = require('parcel-bundler/src/assets/JSAsset');

@luke-robertson
Copy link

@DeMoorJasper

Thanks a lot, thats fixed the issue, fastest help iv ever had on here !

Should i raise a bug with that repo or is this a core fix ?

Thanks

@DeMoorJasper
Copy link
Member

@DesignAlchemy probably a good idea, the plugin should be extending Asset instead of JSAsset. (although I'm not sure if that would be possible in the eslint case)

@natew This bug should be fixed in the latest svg plugin, is this fixed? Than I can close this issue.

@natew
Copy link
Author

natew commented May 12, 2018

@DeMoorJasper I don't see a new version of the svg plugin in the last month I'm on latest.

Removing the plugin actually still breaks the same way. I have a custom babel-config using the following plugins:

babel-plugin-transform-decorators-legacy-without-clutter
babel-plugin-transform-class-properties
babel-plugin-root-import
babel-preset-env
babel-preset-react
babel-preset-stage-1
babel-plugin-macros

as well as two custom one's we've built, so not sure how to debug that.

Edit: removing babel-plugin-macros fixed this.

@natew
Copy link
Author

natew commented May 12, 2018

Although now our custom plugin spits out an error where there was none with 1.6.2.

image

@DeMoorJasper
Copy link
Member

I've tried looking into this today and wasn't able to reproduce any of these issues.
Could you provide a test project that fails @natew

@natew
Copy link
Author

natew commented May 14, 2018

Yea I'll have to wait for a big window because the app itself is big with many dependencies, including custom babel configs and features within it that rely on that. Which means some pretty intense manual binary searching.

No chance there's some way to spit out an error that's closer to whats actually going on? Debugging cannot read x of undefined with no pointer to where is an incredibly tough error, and there's a ton of issues in the parcel issue queue that seem to run into it. Adding a few try/catch around various places would allow telling where things go wrong, no?

@natew
Copy link
Author

natew commented May 22, 2018

Added a log before the error:

image

And I see this:

{ idx: 19, child: 0, type: 'response', contentType: 'data' }
0
Child {
  module: undefined,
  childId: undefined,
  callQueue: [],
  responseQueue: Map {},
  responseId: 0,
  maxConcurrentCalls: 10 }
'run'

I did swap out a few transforms so they are mostly standard now. Just one custom jsx one. Will keep poking around.

@natew
Copy link
Author

natew commented May 22, 2018

Logging out the data, and it seems to start with a font file:

data is { type: 'request',
  idx: 5,
  child: 0,
  method: 'run',
  args:
   [ '/Users/nw/projects/motion/orbit/apps/site/public/fonts/nucleo-mini.eot',
     { name: '@mcro/site',
       private: true,
       version: '1.5.1',

@natew
Copy link
Author

natew commented May 22, 2018

Yep that seems to be it, if I remove the import it goes away. The fonts are loaded via a css file like so:

@font-face {
  font-family: 'Nucleo Mini';
  src: url('../fonts/nucleo-mini.eot');
  src:
    url('../fonts/nucleo-mini.eot') format('embedded-opentype'),
    url('../fonts/nucleo-mini.woff2') format('woff2'),
    url('../fonts/nucleo-mini.woff') format('woff'),
    url('../fonts/nucleo-mini.ttf') format('truetype'),
    url('../fonts/nucleo-mini.svg') format('svg');
  font-weight: normal;
  font-style: normal;
}

Would be super helpful to log out the filename on this error in particular.

Now I run into another issue which I can check out separately.

@DeMoorJasper
Copy link
Member

DeMoorJasper commented May 22, 2018

After seeing your logs this is definitely the cause

Child {
  module: undefined, // This should be the path of parcel-worker
  childId: undefined, // This shouldn't be undefined
  callQueue: [],
  responseQueue: Map {},
  responseId: 0,
  maxConcurrentCalls: 10
}

Not sure what causes it though, I'll look into it if I have some time

@natew
Copy link
Author

natew commented May 22, 2018 via email

@DeMoorJasper
Copy link
Member

DeMoorJasper commented May 22, 2018

I have no clue, it should work perfectly. A font should definitely not cause a worker bug.

If it would cause an error inside asset parsing it would make more sense. But that's not the case

@hasparus
Copy link
Contributor

hasparus commented May 28, 2018

This hack (from #637) fixed it for me 😮

My dirty hack was to open node_modules/parcel-bundler/src/WorkerFarm.js and at line 26 add the line options.maxCallTime = 1000;

parcel-fix

@antony
Copy link

antony commented May 29, 2018

I get the same error when running watch with:

    "parcel-bundler": "1.8.1",
    "parcel-plugin-svelte": "1.1.6"

If I Ctrl + C the process and then run it again, the problem goes away. Sometimes I then edit an unrelated components, and it comes back. Makes it quite hard to develop.

@DeMoorJasper
Copy link
Member

Could you check if this still happens when using #1587 ?

@DeMoorJasper
Copy link
Member

I have been able to consistently reproduce this when running parcels master branch through node 6, #1587 should fix this

@maxbeier
Copy link

maxbeier commented Jul 8, 2018

Hi,

I have a similar problem as natew, even with #1587.

I'm using a plugin to import the content of text files as raw strings (which is quasi TextAsset.js from parcel-plugin-test, but loading Asset from the package (const { Asset } = require('parcel-bundler')) as it's described in the docs).

When using it, other assets (e.g. React.js) are overridden with the content of one of the imported text files. It looks like they are getting the same ID as other assets. Arbitrarily changing the ID for the text assets (e.g. this.id += 500; in the constructor) or importing Asset relatively (const Asset = require('../parcel-bundler/src/Asset.js')) solves the problem.

Strangely, it only happens when the assets are imported from a file in a subfolder, so importing src/test/foo.txt from src/App.js works, but from src/test/App.js doesn't.

@DeMoorJasper
Copy link
Member

@maxbeier Could you create a reproducable example?

@maxbeier
Copy link

maxbeier commented Jul 8, 2018

I tried to but now it's gone. It was the same as in parcel-plugin-svelte#20. It seems that removing node_modules (yes, should have done this way earlier) and reinstalling fixed it, but I have no idea why.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants