Conversation
| expect(await iterator.next()).toEqual({ | ||
| done: false, | ||
| value: { event: "done", id: "EVENT_2", data: "{}" }, | ||
| }); |
There was a problem hiding this comment.
I think this is a bug, rather than a feature because it means that we always need to check event.event === "output" before accessing event.data. The toString function kind of hides this but it doesn't work with JSON.stringify().
I think actually we want to return the done event from the iterator rather than yielding it. Then the done iterator will look like:
expect(await iterator.next()).toEqual({ done: true, value: { event: "done", ... } });
There was a problem hiding this comment.
That sounds reasonable to me. Any reason not to make that change to return for done?
There was a problem hiding this comment.
It's technically a breaking change, but unclear how much of an issue it would cause. There's nothing you can do with it except listen for it and ignore it.
|
@mattt can we punt on the |
|
Closing in favor of #214 |
There's a subtle bug in the current
Streamimplementation where if the server emits lines in several chunks then we get "null" events in the async iterator.For example:
Will result in:
This PR fixes this, plus a few bugs in the
Streamimplementation:decode()function in theStreamclass processes full lines by retaining the last line of the current chunk and appending it to the start of the next chunk before splitting on newlines.validateWebhookwhich returns aPromise<boolean>but is typed to returnboolean.