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

4.0.x crashes with 'Cannot read property 'apply' of undefined' #133

Closed
swernerx opened this issue Oct 1, 2019 · 6 comments · Fixed by #135
Closed

4.0.x crashes with 'Cannot read property 'apply' of undefined' #133

swernerx opened this issue Oct 1, 2019 · 6 comments · Fixed by #135

Comments

@swernerx
Copy link

swernerx commented Oct 1, 2019

I am using Ora inside Preppy. Unfortunately updating to 4.0.x seems to break in some cases with the following error

TypeError: Cannot read property 'apply' of undefined:

Stack Trace:
  - ~/ora/index.js:236 emit()
  - _stream_readable.js:964 pause()
  - ~/ora/index.js:247 stopDiscardingStdin()
  - ~/ora/index.js:209 stop()
  - ~/preppy/bin/preppy:399 buildEnd()
  - ~/rollup/dist/rollup.js:16616 then()

Probably we should add another if-block to check whether the _stdinOldEmit is still defined.

Any help would be appreciated.

@swernerx swernerx changed the title 4.0.x crashes inside Preppy 4.0.x crashes with 'Cannot read property 'apply' of undefined' Oct 1, 2019
swernerx added a commit to sebastian-software/preppy that referenced this issue Oct 1, 2019
@sindresorhus
Copy link
Owner

// @stroncium

@stroncium
Copy link
Contributor

stroncium commented Oct 1, 2019

@swernerx Can you tell me how to reproduce this(file structure + command for preppy is ok)?
Weird thing is we do

if (this._stdinOldEmitOwnProperty) {
	stdin.emit = this._stdinOldEmit;
} else {
	delete stdin.emit;
}

this._stdinOldRawMode = undefined;
this._stdinOldEmit = undefined;
this._stdinOldEmitOwnProperty = undefined;

so it shouldn't be possible our version of stream.emit is called after _stdinOldEmit was unset.

@swernerx
Copy link
Author

swernerx commented Oct 1, 2019

That's probably a tricky one because I don't see it everywhere... today I had it in one of my other OSS projects. Here is the branch which fails: https://github.com/sebastian-software/universal-dotenv/tree/ora-issue-133 to execute npm test/npm run prepare.

Hope this helps. Please tell me if you need something else. Thanks!

@stroncium
Copy link
Contributor

@swernerx Ok, so I traced the problem. ora doesn't support multiple spinners running simultaneously, and that's what happens in your case.

I think I should be able to fix this exact problem to at least make it to not crash, but you probably should change your code as well, as ora spinners are not expected to be displayed properly anyway.

@swernerx
Copy link
Author

swernerx commented Oct 2, 2019

Did not know that it is not meant to run in parallel... that's a pity. I will probably check how I can revamp what's implemented in Preppy.

@stroncium
Copy link
Contributor

stroncium commented Oct 2, 2019

@swernerx Well, it's not really mission critical if there will be minor glitches, so maybe it will work for you just as it is. Tbh, I didn't notice any while testing, so maybe it works good enough for you. It's just that it isn't officially supported as far as I know.

As for the patching the problem you encountered, I need to analyze one more bug and check if it's related before finishing this.

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

Successfully merging a pull request may close this issue.

3 participants