fix: support responses exceeding high watermark#782
Conversation
| await expect(response.text()).resolves.toBe('original-response') | ||
| }) | ||
|
|
||
| it('big response', async () => { |
There was a problem hiding this comment.
Can you tell us more what was the problem big responses were exhibiting? Was there some error being thrown? Let's give this test case a descriptive name.
There was a problem hiding this comment.
At the consumer level, it checks whether we support 1MB responses. On a technical level, it verifies that we properly forward drain events for streams larger than the high water mark.
| }) | ||
|
|
||
| it('big response', async () => { | ||
| const responseBody = new Array(1024 * 1024 + 1).join('.') |
There was a problem hiding this comment.
Wouldn't it be better to create a Uint8Array of the same size instead?
| protected abstract setup(): void | ||
|
|
||
| public apply(): void { | ||
| if (this.readyState === InterceptorReadyState.DISPOSED) { |
There was a problem hiding this comment.
But we still need a guard to prevent calling apply() when the interceptor is already applied. I believe the fix here is to change:
if (this.readyState === InterceptorReadyState.ACTIVE) {| expect(listener).not.toHaveBeenCalled() | ||
| }) | ||
|
|
||
| it('can apply after disposal', () => { |
There was a problem hiding this comment.
| it('can apply after disposal', () => { | |
| it('applies the interceptor after disposal', () => { |
| }) | ||
|
|
||
| it('can apply after disposal', () => { | ||
| class MyInterceptor extends Interceptor<{ test: TypedEvent }> { |
There was a problem hiding this comment.
| class MyInterceptor extends Interceptor<{ test: TypedEvent }> { | |
| class MyInterceptor extends Interceptor<{}> { |
Or any, if it accepts it.
| } | ||
| const interceptor = new MyInterceptor() | ||
|
|
||
| interceptor.apply() |
There was a problem hiding this comment.
Do we also need readyState assertions after individual actions? That way, we can guard against false positive/negatives by making sure every state transitions indeed produces the correct state (readyState).
kettanaito
left a comment
There was a problem hiding this comment.
Looks good to me!
I polished a few things, fixed the interceptors.test.ts file name casing.
Uh oh!
There was an error while loading. Please reload this page.