Fix: Cannot read properties of null for setRawMode#41335
Fix: Cannot read properties of null for setRawMode#41335asaid-0 wants to merge 3 commits intonodejs:mainfrom
Conversation
| ReadStream.prototype.setRawMode = function(flag) { | ||
| flag = !!flag; | ||
| const err = this._handle.setRawMode(flag); | ||
| const err = this._handle && this._handle.setRawMode(flag); |
There was a problem hiding this comment.
This should be covered by a test. Also, is it correct that this function does not fail if this._handle == null?
There was a problem hiding this comment.
Thank you for the review
I think it's safe as long as this._handle would be null if this function is called when using the terminal.
also, I found this check in readline interface:
node/lib/internal/readline/interface.js
Lines 349 to 350 in f81c627
I have covered this issue by a test
There was a problem hiding this comment.
| const err = this._handle && this._handle.setRawMode(flag); | |
| const err = this._handle?.setRawMode(flag); |
| const r = require('repl').start(); | ||
|
|
||
| // Should not throw. | ||
| r.write('process.stdin.push(null)\n'); | ||
| r.write('.exit\n'); |
There was a problem hiding this comment.
This test already passes with current version of Node.js, that means it's failing to replicate the issue at hand.
node/doc/guides/collaborator-guide.md
Lines 204 to 205 in 406e6d8
|
Superseded by #43803. |
Fixes #41330