lambda-local icon indicating copy to clipboard operation
lambda-local copied to clipboard

lambda-local, when run with --wait-empty-event-loop, throws "No such module: timer_wrap"

Open lilsweetcaligula opened this issue 3 years ago • 3 comments

Hi! Thank you for your work on the package. There seems to be an issue with the --wait-empty-event-loop option that occurs on versions of Node.js 11 and greater. lambda-local, when run with the --wait-empty-event-loop option, throws an error:

Error: No such module: timer_wrap
    at process.binding (node:internal/bootstrap/loaders:144:11)
    at Object.waitForNodeJS ([redacted]/lambda-local/build/lib/utils.js:148:37)

My Node.js version is:

$ node -v
v16.4.2

This seems to be related to a similar issue in another package: https://github.com/myndzi/wtfnode/issues/32

Apparently timer_wrap has been deprecated in Node.js 11, and async_hooks must be used instead.

lilsweetcaligula avatar Sep 16 '21 05:09 lilsweetcaligula

If anyone stumbles across this issue in the future, and the issue has not yet been addressed by that time, - then you may try the following dirty workaround:

  • clone this repo
  • go to ./src/lib/utils.ts
  • scroll down to the definition of the waitForNodeJs function
  • replace the definition with:
export function waitForNodeJS(cb) {
  setTimeout(cb, 1e3);
}
  • build the project by running npm build, if any build errors pop up, they should be easy to address
  • run lambda-local from ./build/cli.js

lilsweetcaligula avatar Sep 16 '21 05:09 lilsweetcaligula

Hmm thanks for the report. We'll need to update that function

gpotter2 avatar Sep 25 '21 12:09 gpotter2

Note to self: investigate how wtfnode does it (https://github.com/myndzi/wtfnode/blob/master/index.js). The API has been completly changed

gpotter2 avatar Dec 22 '21 22:12 gpotter2

Fixed in 2.0.3 ! sorry for the delay

gpotter2 avatar Sep 12 '22 17:09 gpotter2

@gpotter2 It's okay. Thank you!

lilsweetcaligula avatar Sep 12 '22 18:09 lilsweetcaligula