Repository navigation
Conversation
A null record passed the 'Invalid Record' check because typeof null is 'object'. The sync API then threw a TypeError for a first null record and wrote an empty row for a later one. The callback API wrote null to the stream, which throws ERR_STREAM_NULL_VALUES inside setImmediate, so the process crashed and the callback never ran. Null records now fail with 'Invalid Record: expect an array or an object, got null', thrown by the sync API and passed to the callback.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A
nullrecord slips past the "Invalid Record" check in__transform, becausetypeof nullis"object". What happens next depends on the API:The callback case is the worst one:
writer()runs insetImmediate, sostringifier.write(null)throws outside the caller's reach, the process crashes and the callback is never called. Other bad records (undefined,1,true) already reach the callback as anInvalid Recorderror.Changes:
__transformnow rejectsnullwithInvalid Record: expect an array or an object, got null, the same error as other non-record values. The sync API throws it.nullinto the stream (streams reserve it for end of input). It destroys the stringifier with that same error, so the callback (orerrorlistener) gets it.Tests: 2 new cases in
test/api.sync.jsand 1 intest/api.callback.js. All 3 fail on master (wrong TypeError, no throw, uncaught exception) and pass with the fix.npm testin csv-stringify (246 passing) and thecsvpackage tests pass; lint andtscare clean. Generateddistis left to the release build.