Repository navigation
Closed as not planned
Closed as not planned
Copy link
Labels
streamIssues and PRs related to Node.js streams.Issues and PRs related to Node.js streams.
Description
- Version: v12.14.1
- Platform: Darwin Kernel Version 19.2.0
- Subsystem: Streams
There are some change introduced in 12.14.1 in process.stdout which created a circular dependency. This behaviour is not detected in 12.14.0, and can't find any reference for changes
in published change log.
Here is the simple code to reproduce the issue in 12.14.1
➜ nvm use 12.14.1
➜ node -i
Welcome to Node.js v12.14.1.
Type ".help" for more information.
> JSON.stringify(process.stdout)
Thrown:
TypeError: Converting circular structure to JSON
--> starting at object with constructor 'WriteStream'
| property '_writableState' -> object with constructor 'WritableState'
| property 'afterWriteTickInfo' -> object with constructor 'Object'
--- property 'stream' closes the circle
at JSON.stringify (<anonymous>)
>
It works well with 12.14.0
➜ nvm use 12.14.0
➜ node -i
Welcome to Node.js v12.14.0.
Type ".help" for more information.
> JSON.stringify(process.stdout)
'{"connecting":false,"_hadError":false,"_parent":null,"_host":null,"_readableState":{"objectMode":false,"highWaterMark":16384,"buffer":{"head":null,"tail":null,"length":0},"length":0,"pipes":null,"pipesCount":0,"flowing":null,"ended":false,"endEmitted":false,"reading":false,"sync":true,"needReadable":false,"emittedReadable":false,"readableListening":false,"resumeScheduled":false,"paused":true,"emitClose":false,"autoDestroy":false,"destroyed":false,"defaultEncoding":"utf8","awaitDrain":0,"readingMore":false,"decoder":null,"encoding":null},"readable":false,"_events":{},"_eventsCount":3,"_writableState":{"objectMode":false,"highWaterMark":16384,"finalCalled":false,"needDrain":false,"ending":false,"ended":false,"finished":false,"destroyed":false,"decodeStrings":false,"defaultEncoding":"utf8","length":0,"writing":false,"corked":0,"sync":false,"bufferProcessing":false,"writecb":null,"writelen":0,"bufferedRequest":null,"lastBufferedRequest":null,"pendingcb":1,"prefinished":false,"errorEmitted":false,"emitClose":false,"autoDestroy":false,"bufferedRequestCount":0,"corkedRequestsFree":{"next":null,"entry":null}},"writable":true,"allowHalfOpen":false,"_sockname":null,"_pendingData":null,"_pendingEncoding":"","server":null,"_server":null,"columns":210,"rows":80,"_type":"tty","fd":1,"_isStdio":true}'
>
I don't know if it's a bug or an explicit change made in interface. If its known change, then must be reported to the change log.
Reacted by Florian Spieß and loclv
Metadata
Metadata
Assignees
Labels
streamIssues and PRs related to Node.js streams.Issues and PRs related to Node.js streams.
Activity
[-]Some change sin 12.14.1 cause circular dependency for process.stdout[/-][+]Node 12.14.1 cause circular dependency for process.stdout[/+][-]Node 12.14.1 cause circular dependency for process.stdout[/-][+]process.stdout cannot be JSON.stringify()ed because of circular dependency[/+]addaleax commentedon Feb 20, 2020
@nazarhussain Since nobody has replied here … there is an open PR that would fix this for the time being, but stringifying Node.js streams using
JSON.stringifyis generally not supported, and it would be best if this is avoided either way.nazarhussain commentedon Feb 20, 2020
I agree stringifying a stream should be avoided. But we should consider it a breaking change and introduce properly with change long. Many packages may be using this change will be breaking for them. As what happens in my case, I found it because it was used in our product.
avivkeller commentedon Jul 11, 2024
This appears to be no-longer reproducible:
{"connecting":false,"_hadError":false,"_parent":null,"_host":null,"_closeAfterHandlingError":false,"_events":{},"_readableState":{"highWaterMark":0,"buffer":[],"bufferIndex":0,"length":0,"pipes":[],"awaitDrainWriters":null},"_writableState":{"highWaterMark":65536,"length":0,"corked":0,"writelen":0,"bufferedIndex":0,"pendingcb":0},"allowHalfOpen":false,"_eventsCount":1,"_sockname":null,"_pendingData":null,"_pendingEncoding":"","server":null,"_server":null,"columns":200,"rows":16,"_type":"tty","fd":1,"_isStdio":true}