-
-
Notifications
You must be signed in to change notification settings - Fork 232
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
fix(tokenizer): Drop chunks after emitting tokens #432
Conversation
Fixes #357 Co-Authored-By: Masaki Hara <41755+qnighy@users.noreply.github.com>
Otherwise we might miss some data
And use it to emit text blocks from sax parser as soon as we might drop the buffer.
@@ -536,6 +542,7 @@ export class Tokenizer { | |||
if (this.currentCharacterToken.type !== type) { | |||
this.currentLocation = this.getCurrentLocation(0); | |||
this._emitCurrentCharacterToken(this.currentLocation); |
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.
We can't drop the parsed chunk in _emitCurrentCharacterToken
, as it is called from prepareToken
and could remove the buffer for the token right after the character token.
The `close` doesn't seem to work in Node 12.
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.
not my area of expertise in this code base. But if the test was broken before and works now, 👍
Thanks a lot for the fix! |
Fixes #292, #357
We would sometimes drop chunks before the corresponding tokens were processed by the rewriting stream. This led to #292. Now, we will drop buffers after emitting events.
BREAKING CHANGE: The SAX parser and rewriting stream will now emit text events when the underlying buffer will be dropped right after the event.
@qnighy I've adopted your test from #357 — hope that's okay! I'd also love it if you could make sure this works for you.