8000 Release version 14 by mikicho · Pull Request #2813 · nock/nock · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Release version 14 #2813

New issue 8000

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

Merged
merged 32 commits into from
Jan 24, 2025
Merged

Release version 14 #2813

merged 32 commits into from
Jan 24, 2025

Conversation

mikicho
Copy link
Contributor
@mikicho mikicho commented Nov 30, 2024

We moved to mswjs/interceptors as interception logic. Separation of the interception and mocking logic will enable us to maintain high-quality interception code across Node and focus on mocking features.

As part of the migration, we increased our compatibility with Node.js significantly:

  1. Request (http.get/request) interception resolution is no longer sync.
  2. socket.authorized now returns false. This is the case most of the time.
  3. headers matcher gets non-string values.
  4. socket ref/unref return this.
  5. response rawHeaders no longer return arrays.
  6. We no longer support undefined content-length
  7. GET requests no longer may have body.
  8. 204, 205, 304 responses can not have body.

Regressions

  1. drop support for delayConnection

I skipped a few failing tests that I plan to fix as part of the interception logic cleanup and refresh I want to do for nock.

CC @nock/maintainers

gr2m and others added 30 commits February 3, 2024 12:17
BREAKING CHANGE: drop support for Node < 18
* fix: replace debug module with node builtin debug

* update readme

* use %s instead of %o

* remove comment

* use %s instead of %o

* add test

* fix
Bumps [sinon](https://github.com/sinonjs/sinon) from 15.2.0 to 17.0.1.
- [Release notes](https://github.com/sinonjs/sinon/releases)
- [Changelog](https://github.com/sinonjs/sinon/blob/main/docs/changelog.md)
- [Commits](sinonjs/sinon@v15.2.0...v17.0.1)

---
updated-dependencies:
- dependency-name: sinon
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Michael Solomon <micheal540@gmail.com>
* fix:mapValues should not modify object in place

* test:add tests to ensure objects are not modified
* fix: remove unused setInterval spy

* fix: delete timer references after callback

This way we don't hold any strong reference to potentially
large setTimeout/setImmediate contexts any more.

Since we use neither `clearTimeout`, nor `clearImmediate`,
we can just ignore those cases and don't need to install
spies to handle deliberate clears.
Copy link
github-actions bot commented Dec 4, 2024

🎉 This PR is included in version 14.0.0-beta.19 🎉

The release is available on:

Your semantic-release bot 📦🚀

@mikicho mikicho marked this pull request as ready for review December 4, 2024 20:29
Copy link
Member
@gr2m gr2m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feel free to merge at your own discretion 🚀

@gr2m
Copy link
Member
gr2m commented Dec 4, 2024

I can also merge it if you like. We should use rebase & merge to make sure we get the commits, and make sure there is a BREAKING CHANGE: in there

@mikicho
Copy link
Contributor Author
mikicho commented Dec 5, 2024

@gr2m I'd love to get your help with this, as in not very familiar with this process.

@gr2m
Copy link
Member
gr2m commented Dec 17, 2024

Okay the process is as follows

  1. Enable "rebase and merge" button
  2. When merged into main, semantic-release will look at all new commits and derive the changelogs from it. I double checked and there is at least one commit with a BREAKING CHANGE: ... note in the commit body, so it will release a breaking verison
  3. That will create a new tag and release automatically. Once it was created, semantic-release will comment on this pull request and others that are included in that release.

We can manually update the changelog to be more easily be used as an upgrade guide.

Happy to do it and watch the release in case something goes wrong. Just let me know if you like me to do it a certain day/time

@mikicho
Copy link
Contributor Author
mikicho commented Dec 18, 2024

@gr2m I see..

Happy to do it and watch the release in case something goes wrong. Just let me know if you like me to do it a certain day/time

I believe we're ready. Please feel free to merge this whenever you have the time. :)

@mikicho
Copy link
Contributor Author
mikicho commented Jan 24, 2025

@gr2m no pressure, just curious if you have some time soon to release this.

@gr2m
Copy link
Member
gr2m commented Jan 24, 2025

Looking into it now

@gr2m gr2m merged commit ef3f158 into main Jan 24, 2025
28 checks passed
@gr2m gr2m deleted the beta branch January 24, 2025 21:38
Copy link

🎉 This PR is included in version 14.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@gr2m
Copy link
Member
gr2m commented Jan 24, 2025

There we go! Feel free to update the release notes with more detail as you see fit.

@gr2m
Copy link
Member
gr2m commented Jan 24, 2025

I really appreciate all the amazing work you and other contributors put into it. I don't have the mental space and time to give all your work its due credit but I will once things get better for me. Open Source at its best, thank you <3

@mikicho
Copy link
Contributor Author
mikicho commented Jan 24, 2025

I couldn't have done this without your openness and warm welcome 🙏

@brendandburns
Copy link

@mikicho this appears to have broken some logic that we were using to simulate a failure halfway through a response (e.g. body stream gets broken/disconnected halfway through responding)

Is there a good way to do this with the new approach to fetch response integration?

Thanks!

@mikicho
Copy link
Contributor Author
mikicho commented Jan 31, 2025

@brendandburns Can you please create an issue with minimal reproduction of the error you get?
IIRC, I think you can just destroy the stream instead, which would give you the same effect, but I'm not 100% sure.

@cjihrig
Copy link
cjihrig commented Feb 1, 2025

@mikicho please see kubernetes-client/javascript#2182 (comment) for a reproduction using only nock, the latest node-fetch, and Node core modules. It's only about 50 lines of code. The issue seems to be 'error' events that are no longer emitted. The breaking change seems to have occurred in nock@14.0.0-beta.8, which only has one change.

@brendandburns
Copy link

Pasting the repro from @cjihrig here, just for simplicity:

import assert from 'node:assert';
import { createInterface } from 'node:readline';
import { PassThrough } from 'node:stream';
import fetch from 'node-fetch';
import nock from 'nock';

const stream = new PassThrough();
const expectedErr = new Error('boom!');
let response;

const scope = nock('http://foo.com');
const s = scope
  .get('/bar')
  .reply(200, function() {
    this.req.on('response', (r) => {
      response = r;
    });
    stream.push(JSON.stringify({ name: 'obj1' }) + '\n');
    stream.push(JSON.stringify({ name: 'obj2' }) + '\n');
    return stream;
  });

const res = await fetch('http://foo.com/bar');
assert.strictEqual(res.status, 200);

const waitForLines = Promise.withResolvers();
const waitForError = Promise.withResolvers();
const lines = [];
let actual;

const readline = createInterface(res.body);

readline.on('error', (err) => {
  actual = err;
  waitForError.resolve();
});

readline.on('line', (line) => {
  lines.push(line);
  if (lines.length === 2) {
    waitForLines.resolve();
  }
});

await waitForLines.promise;
assert.deepStrictEqual(lines, [
  JSON.stringify({ name: 'obj1' }),
  JSON.stringify({ name: 'obj2' }),
]);

response.destroy(expectedErr);
await waitForError.promise;
assert.strictEqual(actual, expectedErr);
console.log('done!');

@glasser
Copy link
glasser commented May 15, 2025

Is there a migration guide or list of backwards-incompatible changes for Nock v14? I'm trying to upgrade and running into some errors that I am not seeing issues about. I am happy to dive in and create a good reproduction, but if it's just that I haven't made some change on my end that would be good to know. The errors all look like this, for what it's worth:

    TypeError: Cannot read properties of undefined (reading 'address')

      at MockHttpSocket.passthrough (../../node_modules/@mswjs/interceptors/src/interceptors/ClientRequest/MockHttpSocket.ts:189:27)
      at _ClientRequestInterceptor.onRequest (../../node_modules/@mswjs/interceptors/src/interceptors/ClientRequest/index.ts:151:21)

@mikicho
Copy link
Contributor Author
mikicho commented May 16, 2025

@glasser There is no migration guide for version 14, as it aims to maintain the same API and behavior as much as possible. All the differences are documented in this PR description: #2813 (comment).

I am happy to dive in and create a good reproduction

If you think this is a bug, please open an issue with a simple reproduction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants
0