-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: Not Applicable
-
Component/s: None
-
Empty show more show less
From the node stream docs:
Custom Writable streams must call the new stream.Writable([options]) constructor and implement the writable._write() and/or writable._writev() method.
GridFSBucketWriteStream does not call the stream.Writable constructor. Because node v13 changed the implementation of stream.Writable.destroy(), calling .destroy() on a GridFSBucketWriteStream throws an error of "TypeError: Cannot read property 'destroyed' of undefined". This happens, because stream.Writable._writableState is set in the stream.Writable constructor, but is not set in GridFSBucketWriteStream. .destroy() tries to access ._writableState.destroyed.
Even though .destroy() probably didn't do anything when called for GridFSBucketWriteStream, it's non-failing implementation allows the use of pump / stream.pipeline, which calls .destroy when available.
pump is used by multer-gridfs-storage (used to stream files into gridfs in express apps), which now fails with node v13 under certain conditions.
It is suggested that the GridFS streams properly inherit from the corresponding node streams. The current use of util.inherits is discouraged in the node docs as well:
Usage of util.inherits() is discouraged. Please use the ES6 class and extends keywords to get language level inheritance support.