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

process.binding deprecation #89

Open
demurgos opened this issue May 10, 2019 · 1 comment
Open

process.binding deprecation #89

demurgos opened this issue May 10, 2019 · 1 comment

Comments

@demurgos
Copy link
Contributor

Node started to deprecate process.binding: https://nodejs.org/dist/latest-v11.x/docs/api/deprecations.html#deprecations_dep0111_process_binding

This function is used by spawn-wrap to patch spawnSync.

It is possible to avoid patching the internals at the top level by creating a wrapped spawn function. The main issue is caused by processes deep in the process tree: spawn-wrap tries to hook into user-code spawning processes and we cannot change it so we still have to patch the internals.

There is an open Node issue discussing the issue: nodejs/node#27344

/cc @isaacs @bcoe @coreyfarrell

@demurgos
Copy link
Contributor Author

demurgos commented May 11, 2019

I've thought about this problem and I think it's possible to avoid relying on process.binding.
There are 3 points were you can act:

  • Overwrite the internal Node bindings (current solution for spawnSync)
  • Overwrite the functions exported by the child_process module (≃ current solution for spawn)
  • Do not overwrite any functions but return a new one (requires changes in user code: does not work here)

I think that it is possible to lift the current spawnSync patch to overwrite the child_process functions instead of the process bindings. Instead of patching a single point, we'd have to patch all the child_process sync functions (execFileSync, execSync and spawnSync) but it should be doable.

What's interesting is that the 2 highest levels can be implemented together. Instead of returning the wrapper function to the user, set it on the child_process exports.

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

No branches or pull requests

1 participant