You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
it('given a hanging stream, should timeout', async () => {
jest.useFakeTimers();
const readable = new Readable({
read() {
/**
* Override _read. Keep the stream open by never pushing null to the buffer
*/
},
});
readable.push(Buffer.from(`1234567890`));
const stream = () =>
pipe(
Stream.fromAsyncIterable(readable, (e) => e),
Stream.timeoutFail(() => new Error('Timeout'), '2 seconds'),
Stream.runForEachChunk((chunk) =>
Effect.sync(() => {
console.log(chunk);
}),
),
);
const program = stream();
const promise = Effect.runPromise(program)
.then(console.log)
.catch((e) => expect(e.message).toBe('Timeout'));
await jest.advanceTimersByTimeAsync(10 * 60 * 1000); // 10 minutes
expect.assertions(1);
await promise; // test times out, never resolves
});
What is the expected behavior?
Expect the effect to result in a timeout error
What do you see instead?
Instead the test times out after 45 seconds (our test config)
Additional information
Any workarounds here?
Stream.fromReadableStream isn't applicable here b/c the Web API stream is not the same as the node stream.
The timeout works when a generator is provided, example below. Unfortunately the code is receiving a Readable from an HTTP request, so the difference in behavior between Readable and Iterator is likely to result in the stream hanging in production.
What version of Effect is running?
3.13.2
What steps can reproduce the bug?
I can reproduce this in jest,
What is the expected behavior?
Expect the effect to result in a timeout error
What do you see instead?
Instead the test times out after 45 seconds (our test config)
Additional information
Any workarounds here?
Stream.fromReadableStream
isn't applicable here b/c the Web API stream is not the same as the node stream.The timeout works when a generator is provided, example below. Unfortunately the code is receiving a
Readable
from an HTTP request, so the difference in behavior between Readable and Iterator is likely to result in the stream hanging in production.The text was updated successfully, but these errors were encountered: