node/test/parallel/test-stream-toWeb-allows-server-response.js
Debadree Chatterjee 2ec418984b
lib: allow Writeable.toWeb() to work on http.Outgoing message
Attempted to fix the issue by watering down the condition being
checked in internal/streams/utils isWritableNodeStream utility

Fixes: https://github.com/nodejs/node/issues/44188
PR-URL: https://github.com/nodejs/node/pull/45642
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2022-12-10 17:06:40 +00:00

30 lines
648 B
JavaScript

'use strict';
const common = require('../common');
const { Writable } = require('stream');
const assert = require('assert');
const http = require('http');
// Check if Writable.toWeb works on the response object after creating a server.
const server = http.createServer(
common.mustCall((req, res) => {
const webStreamResponse = Writable.toWeb(res);
assert.strictEqual(webStreamResponse instanceof WritableStream, true);
res.end();
})
);
server.listen(
0,
common.mustCall(() => {
http.get(
{
port: server.address().port,
},
common.mustCall(() => {
server.close();
})
);
})
);