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

Replacing vm.createScript in favour of vm.Script #4534

Merged
merged 4 commits into from May 9, 2024

Conversation

patlux
Copy link
Contributor

@patlux patlux commented Jan 21, 2024

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Proposed changes

It seem's vm.createScript is deprecated, because it's not mentioned in the official docs. This PR replaces vm.createScript by vm.Script.

This was needed by myself to run node-red with bun.sh. vm.createScript is not available in bun, because I think they missed it due of the missing documentation? Not sure.

The advantage of running node-red with bun is support of esm :)

I also opened a PR there to add support for vm.createScript: oven-sh/bun#8312

Checklist

  • I have read the contribution guidelines
  • For non-bugfix PRs, I have discussed this change on the forum/slack team.
  • I have run npm run test to verify the unit tests pass
  • I have added suitable unit tests to cover the new/changed functionality

Copy link

linux-foundation-easycla bot commented Jan 21, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@Steve-Mcl
Copy link
Contributor

This was needed by myself to run node-red with bun.sh. vm.createScript is not available in bun, because I think they missed it due of the missing documentation? Not sure.

NodeJS has not documented createScript since Node V0.12 (24 Nov 2015)

It seem's vm.createScript is deprecated, because it's not mentioned in the official docs. This PR replaces vm.createScript by vm.Script.

My guess is that it was simply undocumented while node was still in beta/pre V1. (tho it is odd that they have kept it around!)


PS: Since you are playing with bun, be aware there is a major problem with GOT (the http request library we use under the hood) + Bun.
You will crash node-red with the exception "A retry listener has been attached already" when attempting to do HTTP requests.

It doesnt look like a quick fix nor does it look like GOT or BUN are in any hurry to resolve it.

@patlux
Copy link
Contributor Author

patlux commented Jan 21, 2024

PS: Since you are playing with bun, be aware there is a major problem with GOT (the http request library we use under the hood) + Bun.

You will crash node-red with the exception "A retry listener has been attached already" when attempting to do HTTP requests.

Sadly yes, I discovered the error just after I created this PR ;(

Switched back to node for now.

@knolleary
Copy link
Member

knolleary commented May 9, 2024

Thanks for this. Given the node.js (undocumented) implementation of createScript is to simply delegate to new Script() this appears to be a pretty sensible change to make.

@knolleary knolleary merged commit 1bb3a0e into node-red:master May 9, 2024
4 checks passed
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.

None yet

3 participants