-
Notifications
You must be signed in to change notification settings - Fork 134
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
Plan of process.binding() deprecation #1482
Comments
|
Note that there are multiple errors we can throw as the end-goal
Yes I guess that comes back to 3 (the ordering question)
Libraries should still see the warning in their tests and get a reminder, if anyone is still watching for their test output (if they happen to run their tests with |
|
I couldn't find a way of doing incremental (synchronous) Zlib inflate on an open file stream using the built in node.js APIs so I reached for the Zlib binding. My issue is that I have a stream with a bunch of deflate blocks. I know the offset of the start of the deflate block I need to inflate, but I don't know where the end of the deflate block is. While I could read in the whole file and pass that to My implementation is something like (to others: don't use this... it's certainly not robust for general purpose applications): function inflate(
zlib: Zlib, // an `init`ialized instance of `process.binding("zlib").Zlib`
state: Uint32Array,
reader: Reader, // helper class to read from a file stream
outSize: number,
) {
const chunkSize = Math.max(constants.Z_MIN_CHUNK, outSize);
const output = Buffer.allocUnsafe(outSize);
let totalInflated = 0;
let outOffset = 0;
while (totalInflated < outSize) {
const chunk = reader.peek(chunkSize);
reader.seek(chunk.byteLength);
let inOffset = 0;
let availInBefore = chunk.byteLength;
let availOutBefore = outSize - outOffset;
// continue running while there is still data to process
while (availInBefore > 0 && availOutBefore > 0) {
// `Z_BLOCK` will process the zlib header and then return. The next time
// it runs it will "inflate" up to the end of the input data, or the end
// of the deflate block (which ever comes first) then return. It will
// *not* continue to the next block of compressed data.
const flush = constants.Z_BLOCK;
zlib.writeSync(
flush,
chunk,
inOffset,
availInBefore,
output,
outOffset,
availOutBefore,
);
const [availOutAfter, availInAfter] = state;
const inBytesRead = availInBefore - availInAfter;
const outBytesWritten = availOutBefore - availOutAfter;
inOffset += inBytesRead;
outOffset += outBytesWritten;
totalInflated += outBytesWritten;
availInBefore = availInAfter;
availOutBefore = availOutAfter;
}
}
return output;
} Maybe there was a way and I just didn't see it? Anyway, before officially deprecating this api a replacement would be really appreciated! |
@joyeecheung I wonder if V8 has an equivalent of Something like that might be useful as an in-between step for changes like this |
@joyeecheung @jasnell given there was no progress on this front, can we get nodejs/node#50687 reopened and landed for v23? |
I don't think I can commit enough time to this to get consensus and spin a vote, so I won't block if someone wants to reland that, but if someone else wants to initiate a vote I would vote -1 to console my conscience. For example this is what you see in a yarn + swc-node session if the Node.js release start to emit runtime warnings for $ yarn init
yarn init v1.22.22
question name (test-yarn): (node:5005) [DEP0111] DeprecationWarning: Access to process.binding('natives') is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
question version (1.0.0):
question description:
question entry point (index.js):
question repository url:
question author:
question license (MIT):
question private:
success Saved package.json
Done in 4.43s.
$ touch yarn.lock
$ yarn set version berry
(node:5026) [DEP0111] DeprecationWarning: Access to process.binding('natives') is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:5037) [DEP0111] DeprecationWarning: Access to process.binding('util') is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
➤ YN0000: You don't seem to have Corepack enabled; we'll have to rely on yarnPath instead
➤ YN0000: Downloading https://repo.yarnpkg.com/4.3.1/packages/yarnpkg-cli/bin/yarn.js
➤ YN0000: Saving the new release in .yarn/releases/yarn-4.3.1.cjs
➤ YN0000: Done with warnings in 0s 71ms
$ yarn add @swc-node/register @swc/core typescript
(node:5058) [DEP0111] DeprecationWarning: Access to process.binding('util') is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
➤ YN0000: · Yarn 4.3.1
➤ YN0000: ┌ Resolution step
➤ YN0085: │ + @swc-node/register@npm:1.10.3, @swc/core@npm:1.6.13, and 40 more.
➤ YN0000: └ Completed in 0s 297ms
➤ YN0000: ┌ Post-resolution validation
➤ YN0086: │ Some peer dependencies are incorrectly met by dependencies; run yarn explain peer-requirements for details.
➤ YN0000: └ Completed
➤ YN0000: ┌ Fetch step
➤ YN0000: ⠼ =======================================-----------------------------------------
(node:5058) [DEP0111] DeprecationWarning: Access to process.binding('util') is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:5058) [DEP0111] DeprecationWarning: Access to process.binding('util') is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:5058) [DEP0111] DeprecationWarning: Access to process.binding('util') is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:5058) [DEP0111] DeprecationWarning: Access to process.binding('util') is deprecated.
➤ YN0000: ⠼ =============================================-----------------------------------
(node:5058) [DEP0111] DeprecationWarning: Access to process.binding('util') is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:5058) [DEP0111] DeprecationWarning: Access to process.binding('util') is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:5058) [DEP0111] DeprecationWarning: Access to process.binding('util') is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:5058) [DEP0111] DeprecationWarning: Access to process.binding('util') is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:5058) [DEP0111] DeprecationWarning: Access to process.binding('util') is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:5058) [DEP0111] DeprecationWarning: Access to process.binding('util') is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:5058) [DEP0111] DeprecationWarning: Access to process.binding('util') is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:5058) [DEP0111] DeprecationWarning: Access to process.binding('util') is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:5058) [DEP0111] DeprecationWarning: Access to process.binding('util') is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:5058) [DEP0111] DeprecationWarning: Access to process.binding('util') is deprecated.
➤ YN0000: ⠴ =========================================================-----------------------
(node:5058) [DEP0111] DeprecationWarning: Access to process.binding('util') is deprecated.
➤ YN0013: │ 24 packages were added to the project (+ 103.57 MiB).
➤ YN0000: └ Completed in 1s 429ms
➤ YN0000: ┌ Link step
➤ YN0000: │ ESM support for PnP uses the experimental loader API and is therefore experimental
➤ YN0007: │ @swc/core@npm:1.6.13 [201f2] must be built because it never has been before or the last one failed
➤ YN0000: └ Completed in 0s 361ms
➤ YN0000: · Done with warnings in 2s 108ms
$ echo 'console.log("Hello world")' > index.ts
$ yarn node --loader @swc-node/register/esm index.ts
(node:5115) [DEP0111] DeprecationWarning: Access to process.binding('util') is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:5126) [DEP0111] DeprecationWarning: Access to process.binding('fs') is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
Hello world And I know that at least the fs binding use case (monkey-patching) is already known for years and no one has been actively working on it to my knowledge, so I don't see the plan of "let's deprecate and get requests" working out well for our users, because there is no guarantee how long it will take to actually release a solution to the request, meanwhile users have to suffer through disruptions like this in their CLIs, especially the ones that prompt and spin progress bars, and that looks very similar to the Buffer constructor situation we had a few years ago. |
@joyeecheung That's why I changed the warning to |
The disruption to prompts and progress bars would be the same as long as the warning is emitted on anya |
This is what you'll see with nodejs/node#48568 in a colored console (I am not sure why I am doing this, research like this should be part of any PR proposing warnings to |
@joyeecheung apart from yarn, where you able to catch what other popular module was affected? |
I am pretty sure whoever proposing the breakage can easily try it out on other popular tools and report back. I don’t want to do it myself because
If others think that the breakage is acceptable without further investigation from whoever proposing the change, and we should just leave users with the warning without any commitment into developing a migration path, I rest my case. I can reconcile with my conscience with the work I committed so far. |
Thanks @joyeecheung, I concur. |
This issue is not new but motivated by nodejs/node#50687, which proposed to
For background in 2021 the plan suggested in nodejs/node#37485 (review) and followed since nodejs/node#37819 was:
I am opening this issue trying to slice the issue into different questions instead of bundling all together into just two different plans, in the hope of figuring out a better compromise.
There are several questions to the deprecation of
process.binding()
:a) Delete
process.binding
completely so that when trying to invoke it, users get an error.b) A function that does no more than emitting a warning and returning empty objects. Users almost always get an error when they try to access an unsupported property, but if the code path is unused, e.g. only loading a
process.binding()
from the top-level but never actually hit the code path using anything from it, it would not fail.c) Leave a low-maintenance and harmless shim in place forever. Users get an error only when they try to use a specific unsupported property.
a) Individually, based on how problematic they are/how difficult it is to provide alternatives
b) Together at once
a) We investigate the impact (e.g. through CITGM), develop and release alternatives on the way, monitor the changes in the impact, before deciding when it's ready to runtime-deprecate it (individually or all together).
b) Runtime-deprecate it directly and mitigate the impact afterwards based on the bug reports/feature requests we receive.
a) Emit runtime warnings unconditionally
c) Non-node_module warnings first, node_module warnings in the next cycle
I think we as @nodejs/tsc need to take a deeper look into these questions and make some decisions before finishing a plan of the deprecation.
The text was updated successfully, but these errors were encountered: