Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClientRequest: doesn't throw error when writing after end on mock responses #460

Open
Tracked by #2517
mikicho opened this issue Sep 29, 2023 · 0 comments
Open
Tracked by #2517
Assignees

Comments

@mikicho
Copy link
Contributor

mikicho commented Sep 29, 2023

const { ClientRequestInterceptor } = require('@mswjs/interceptors/ClientRequest')
const http = require('http');

const interceptor = new ClientRequestInterceptor({
  name: 'my-interceptor',
})
interceptor.apply();
interceptor.on('request', ({ request }) => {
  request.respondWith(new Response('hello'))
});

const req = http.get('http://nowhere.com/', res => {
  console.log('response event');
})
req.end()
req.write('foo')

This should throw: Error [ERR_STREAM_WRITE_AFTER_END]: write after end but it succeeds

@kettanaito kettanaito changed the title should throw error if write after end ClientRequest: doesn't throw error when writing after end on mock responses Sep 30, 2023
@kettanaito kettanaito added this to the Nock compatibility milestone Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants