-
-
Notifications
You must be signed in to change notification settings - Fork 151
Open
Description
const http = require('http');
const stream = require('stream');
const { FetchInterceptor } = require('@mswjs/interceptors/fetch');
const interceptor = new FetchInterceptor();
interceptor.apply();
interceptor.on('request', ({ controller}) => {
const readable = new stream.Readable({
read() {
setTimeout(() => this.push('hello'), 100)
}
})
controller.respondWith(new Response(readable))
})
const server = http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' })
setInterval(() => res.write('hello\n'), 100)
})
server.listen(3000);
(async () => {
const start = process.hrtime.bigint()
const response = await fetch('http://localhost:3000', {
signal: AbortSignal.timeout(300),
})
console.log((process.hrtime.bigint() - start) / BigInt(1e6));
for await (const data of response.body) {
console.log((process.hrtime.bigint() - start) / BigInt(1e6));
console.log(Buffer.from(data).toString())
}
console.log((process.hrtime.bigint() - start) / BigInt(1e6));
})()This process continues to run indefinitely.
It should abort the request for a long response as well.
P.S. this is weird and somewhat unexpected behavior, I must say.
Metadata
Metadata
Assignees
Labels
No labels