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

Node 10 runtime seems to have a default unhandledRejection listener #7

Closed
wants to merge 2 commits into from

Conversation

scionaltera
Copy link

Fixes #6

In the Node 8 runtime there is no unhandledRejection listener, so the strictEqual to 0 passes. In the Node 10 runtime it appears there is one unhandledRejection listener which breaks the assertion.

This change allows 0 or 1 listeners and removes any listeners that are there, which matches the uncaughtException behavior. It appears to work in SAM local but I wouldn't say I have tested it thoroughly yet.

@kyeotic
Copy link
Contributor

kyeotic commented Oct 29, 2019

are you able to run the tests under node 10? I ran into issues when I tried to set this up myself (I used a similar solution to your second commit) with rewire under node 10. It seems there is an issue with rewiring globals after node 9.

This is likely going to require switching to another mocking utility.

@scionaltera
Copy link
Author

scionaltera commented Oct 29, 2019

I tried the logger in my project with my changes in the SAM local Node 10 runtime and that worked.

I just now tried running the tests in Node 10.17.0 and it looks like they just die without much of an error message. I'm not that familiar with the libraries you've used so it'll take some time to track down what's going wrong. Maybe the following will be helpful. I don't think I'll have time to fix it today if it requires switching to a different mocking solution.

$ cat /Users/pkeel1/.npm/_logs/2019-10-29T17_23_17_592Z-debug.log
0 info it worked if it ends with ok
1 verbose cli [ '/Users/pkeel1/.nvm/versions/node/v10.17.0/bin/node',
1 verbose cli   '/Users/pkeel1/.nvm/versions/node/v10.17.0/bin/npm',
1 verbose cli   'run',
1 verbose cli   'test:unit' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'pretest:unit', 'test:unit', 'posttest:unit' ]
5 info lifecycle [email protected]~pretest:unit: [email protected]
6 info lifecycle [email protected]~test:unit: [email protected]
7 verbose lifecycle [email protected]~test:unit: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~test:unit: PATH: /Users/pkeel1/.nvm/versions/node/v10.17.0/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/pkeel1/gitProjects/pkeel1/lambda-logger-node/node_modules/.bin:/Users/pkeel1/.nvm/versions/node/v10.17.0/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/pkeel1/gitProjects/pkeel1/lambda-logger-node/node_modules/.bin:/Users/pkeel1/.nvm/versions/node/v10.17.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:/Users/pkeel1/bin:/Users/pkeel1/Library/Python/2.7/bin
9 verbose lifecycle [email protected]~test:unit: CWD: /Users/pkeel1/gitProjects/pkeel1/lambda-logger-node
10 silly lifecycle [email protected]~test:unit: Args: [ '-c', 'blue-tape "test/**/**.spec.js" | tap-nirvana' ]
11 silly lifecycle [email protected]~test:unit: Returned: code: 1  signal: null
12 info lifecycle [email protected]~test:unit: Failed to exec test:unit script
13 verbose stack Error: [email protected] test:unit: `blue-tape "test/**/**.spec.js" | tap-nirvana`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/Users/pkeel1/.nvm/versions/node/v10.17.0/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:198:13)
13 verbose stack     at ChildProcess.<anonymous> (/Users/pkeel1/.nvm/versions/node/v10.17.0/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:198:13)
13 verbose stack     at maybeClose (internal/child_process.js:982:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid [email protected]
15 verbose cwd /Users/pkeel1/gitProjects/pkeel1/lambda-logger-node
16 verbose Darwin 18.7.0
17 verbose argv "/Users/pkeel1/.nvm/versions/node/v10.17.0/bin/node" "/Users/pkeel1/.nvm/versions/node/v10.17.0/bin/npm" "run" "test:unit"
18 verbose node v10.17.0
19 verbose npm  v6.11.3
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] test:unit: `blue-tape "test/**/**.spec.js" | tap-nirvana`
22 error Exit status 1
23 error Failed at the [email protected] test:unit script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

@kyeotic
Copy link
Contributor

kyeotic commented Oct 29, 2019

Dying without error is caused by a leak in the console mock overriding the global console log, swallowing all the test reporting. I am working on this

@kyeotic kyeotic mentioned this pull request Oct 29, 2019
@kyeotic
Copy link
Contributor

kyeotic commented Oct 29, 2019

closing in favor of #8

@kyeotic kyeotic closed this Oct 29, 2019
@scionaltera scionaltera deleted the node10-compat branch October 29, 2019 21:45
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 this pull request may close these issues.

This package does not work with Node 10.x lambda runtime
2 participants