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

stream: move prefixed files into internal/streams. #11957

Closed
wants to merge 1 commit into from

Conversation

mcollina
Copy link
Member

This simplifies the lib/ folder, and hides _stream_readable.js and
peers into lib/internal/streams. All the tests have been updated to
use the main stream module, rather than requiring from the internals.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows [commit guidelines][]
Affected core subsystem(s)

stream

@nodejs-github-bot nodejs-github-bot added build Issues and PRs related to build files or the CI. stream Issues and PRs related to the stream subsystem. zlib Issues and PRs related to the zlib subsystem. labels Mar 21, 2017
@mcollina
Copy link
Member Author

mcollina commented Mar 21, 2017

cc @nodejs/streams @italoacasas

@cjihrig cjihrig added the semver-major PRs that contain breaking changes and should be released in the next major version. label Mar 21, 2017
@cjihrig
Copy link
Contributor

cjihrig commented Mar 21, 2017

Marking as semver major because this will break code that requires these files directly.

Copy link
Contributor

@cjihrig cjihrig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes LGTM with one nit.

We need to see how widely these files are required directly in the ecosystem. cc: @ChALkeR

node.gyp Outdated
'lib/_stream_duplex.js',
'lib/_stream_transform.js',
'lib/_stream_passthrough.js',
'lib/internal/streams/readable.js',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you keep these with the other lib/internal files.

@mcollina
Copy link
Member Author

@cjihrig done.

@jasnell
Copy link
Member

jasnell commented Mar 21, 2017

Unfortunately we need to keep stubs in lib for these... can be deprecated exports similar to what we do with sys.js. The reason is that by removing these from the core namespace, we open a potential security risk for anyone who happens to be depending on them currently (malicious code could stick it's own _stream_readable.js or whatever into the mix and cause problems).

Moving the actual code into lib/internal is just fine, but for each deleted file, please create a lib/{filename}.js that does something like:

'use strict';

process.emitWarning('The {filename} module is deprecated. Please use ....',
                                   'DeprecationWarning', 'DEP00XX');

module.exports = require('internal/{filename}.js');

(Where DEP00XX is a new static deprecation code added to the doc/api/deprecations.md file)

@mcollina
Copy link
Member Author

@jasnell how long do we need to keep stubs for?

Is it a security attack? If a malicious user can stick a file on disk, I would say the system is already compromised.

@jasnell
Copy link
Member

jasnell commented Mar 21, 2017

Yeah, it's not a significant risk but it's still non-zero. The stubs need to remain long enough to give users sufficient time to move away from using them, which depends entirely on how extensively they are used. A quick search on GitHub for "require('_stream_readable')" returns around 14k hits where people are doing things like var Readable = require('_stream_readable'). It would take a bit of analysis to determine how critical that code might be and how much it is depended on.

@Fishrock123
Copy link
Contributor

We do need to at least deprecate them. We should get some data on the usage before deciding.
I'm generally in favor if things look good though.

@mcollina
Copy link
Member Author

This change make sense if we can get rid of the old files in 9 or 10. Is this the case?

@mcollina
Copy link
Member Author

@Fishrock123 I do not know how to get that data.

@jasnell jasnell requested a review from ChALkeR March 21, 2017 15:27
@jasnell
Copy link
Member

jasnell commented Mar 21, 2017

Assuming the ecosystem usage is not too high, it should be possible to remove the files by Node.js 10.0.0.

@mcollina
Copy link
Member Author

@jasnell @Fishrock123 updated with a deprecation.

@@ -582,6 +582,19 @@ deprecated.
*Note*: `OutgoingMessage.prototype._renderHeaders` was never documented as
an officially supported API.

<a id="DEP0068"></a>
### DEP0068: Usage of _stream_*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, make this `DEP00XX', we can update the number when it lands, that way there's no risk of conflict

Using `require('_stream_readable')`,
`require('_stream_writable')`, `require('_stream_duplex')`
`require('_stream_transform')`, `require('_stream_passthrough')`
is now deprecated.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps show the approved/proper way of getting these references.

Copy link
Member

@jasnell jasnell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally LGTM with a couple of suggestions

@mcollina
Copy link
Member Author

mcollina commented Mar 22, 2017

I would really like to have someone else from @nodejs/streams check this.

@jasnell updated.

Copy link
Contributor

@calvinmetcalf calvinmetcalf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think it looks good, we didn't allow the prefixed access in readable streams the same was, (you needed to do lib/_stream_writable) so I don't see any problem at all

@mcollina
Copy link
Member Author

I will merge on Monday 27th if no one objects.

@italoacasas
Copy link
Contributor

italoacasas commented Mar 22, 2017

@jasnell we need to include the a Copyright in the stub files?

@jasnell
Copy link
Member

jasnell commented Mar 22, 2017

No, the original files are moved and still retain the copyright header. The stubs are new and do not require it.

This was referenced Oct 23, 2017
@Trott Trott removed the tsc-agenda Issues and PRs to discuss during the meetings of the TSC. label Nov 8, 2017
@BridgeAR
Copy link
Member

BridgeAR commented Nov 22, 2017

@mcollina do you have some time soon to rebase?

@jasnell
Copy link
Member

jasnell commented Nov 22, 2017

He's on vacation for the next couple of weeks.

@BridgeAR
Copy link
Member

BridgeAR commented Jan 5, 2018

Ping @mcollina

@BridgeAR
Copy link
Member

Closed due to no progress over a long time.

@mcollina please feel free to reopen when you get to it again.

@BridgeAR BridgeAR closed this Jan 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked PRs that are blocked by other issues or PRs. build Issues and PRs related to build files or the CI. semver-major PRs that contain breaking changes and should be released in the next major version. stream Issues and PRs related to the stream subsystem. zlib Issues and PRs related to the zlib subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.