-
-
Notifications
You must be signed in to change notification settings - Fork 33k
repl: runtime deprecate NODE_REPL_HISTORY_FILE #16505
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
Conversation
lib/internal/repl.js
Outdated
@@ -167,6 +168,12 @@ function setupHistory(repl, historyPath, oldHistoryPath, ready) { | |||
'REPL session history will not be persisted.\n'); | |||
} | |||
if (!threw) { | |||
deprecate( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't seem correct to me. Who calls the function returned by deprecate()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lpinca sorry, I didn't read internal/util source correctly, I thought deprecate auto-printed the deprecation. updated my pr.
lib/internal/repl.js
Outdated
@@ -167,6 +174,8 @@ function setupHistory(repl, historyPath, oldHistoryPath, ready) { | |||
'REPL session history will not be persisted.\n'); | |||
} | |||
if (!threw) { | |||
_printHistoryDeprecation(oldHistoryPath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be called in setupHistory()
iff oldHistoryPath
is not null
or undefined
. By calling it here, it won't be displayed for users who have set the NODE_REPL_HISTORY_FILE
env variable, but opening or parsing that history file throws an Error
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, fair point. But wouldn't we want to only show the error message to NODE_REPL_HISTORY_FILEs that actually parse correctly? If the file is broken, they probably wouldn't be able to convert it to the new file format anyway, right? 😬
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm - ping @lance @maclover7 ?
My guess would be that there's nobody left using the old format anyway by now and that this particular difference would really not matter anyway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for my latency. @addaleax @maclover7 your points are valid. TBH, I think it would be more correct if moved to setupHistory()
, but I won't block the PR on that.
Ping @maclover7 |
eb111f5
to
50cbad1
Compare
lib/internal/repl.js
Outdated
const { deprecate } = require('internal/util'); | ||
const _printHistoryDeprecation = deprecate( | ||
() => path, | ||
'NODE_REPL_HISTORY_FILE is deprecated. Use the plaintext format instead.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might it be more clear to say "use NODE_REPL_HISTORY instead"? That's what the docs say.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with a suggestion
Labeled |
This needs one more TSC approval if it is to land. @nodejs/tsc |
lib/internal/repl.js
Outdated
@@ -167,6 +174,8 @@ function setupHistory(repl, historyPath, oldHistoryPath, ready) { | |||
'REPL session history will not be persisted.\n'); | |||
} | |||
if (!threw) { | |||
_printHistoryDeprecation(oldHistoryPath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: it doesn't seem necessary to pass a value to the function
lib/internal/repl.js
Outdated
@@ -10,6 +10,13 @@ const debug = util.debuglog('repl'); | |||
module.exports = Object.create(REPL); | |||
module.exports.createInternalRepl = createRepl; | |||
|
|||
const { deprecate } = require('internal/util'); | |||
const _printHistoryDeprecation = deprecate( | |||
() => {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: extraneous space after the arrow
removed extra space, good catch @targos |
Seems like on windows the test has some issues? https://ci.nodejs.org/job/node-test-binary-windows/13342/COMPILED_BY=vcbt2015,RUNNER=win10,RUN_SUBSET=1/console |
cc @nodejs/platform-windows trying to debug this locally, it looks like per the TAP extended results the deprecation warning is being emitted (is visible in the tap stack), but for some reason the |
Ping @nodejs/platform-windows PTAL |
The The test is failing because of this test-case: For whatever reason |
Refs: #13876 Just a note that I've been trying to add tests for this, but it's been difficult because it seems like most REPL tests directly patch into internals, and are not run via a child process.
2476814
to
9a8cf0d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@bzoz Tried to remediate, ran another CI, and Windows is still failing. Can you think of why an empty |
I investigated this, I did not diagnose this correctly the first time around, it looks like this: This fails only on Windows because only on that platform this test uses execSync to call The if (deprecated) {
common.hijackStderr(common.mustCall((data) => {
assert.ok(deprecated && depMsg.test(data));
}));
} As you observed in the TAP results, the deprecation message was only displayed once. With the test like this, it will fail for all but the first " |
@bzoz fwiw (and I don't know if this will add anything of value to the conversation), but I mucked around with the history file quite a bit about a year and a half ago. There is a lot of discussion about those changes here. This #7005 (comment) and the few comments below it might shed a little light. At the moment I don't have the bandwidth to dig deeper - just wanted to point out that there has been some work around some of these Windows permissions issues in the past. |
assert.ok(deprecated && depMsg.test(data)); | ||
} | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me it looks like the hijack is called multiple times and will therefore also trigger for tests that have nothing to do with the current test.
So I think the hijack should be deactivated as soon as it is not required anymore.
In that case the inner deprecated
check should also be obsolete.
@maclover7 would you be so kind and have another look? @bzoz I am not sure how to follow your example code in combination with your comment. How should a |
Ping @maclover7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make the test pass on Windows, add {stdio: 'ignore'}
to the execSync
call.
However, this test is broken, since it does not check if the deprecation message was shown at all. This is why common.mustCall
should be used in hijakStderr
. Otherwise, this test will also pass with the current master.
Closing due to long inactivity. To be frank: I personally feel like in this very seldom case it is possible to remove that environment variable without a proper deprecation cycle. The reason is not only that no one has probably really used it for more than a few days but also that I do not see how removing would really do anyone harm. Relying on the repl history file should be very rare... |
Refs: #13876
Just a note that I've been trying to add tests for this, but it's been
difficult because it seems like most REPL tests directly patch into
internals, and are not run via a child process.
Also, not sure if this should even be landing, since it's very close to the v9 release candidate release... cc @jasnell
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
repl