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

Unable to intercept octokit request using msw v2. #2409

Closed
4 tasks done
Lord-Kamina opened this issue Jan 11, 2025 · 2 comments
Closed
4 tasks done

Unable to intercept octokit request using msw v2. #2409

Lord-Kamina opened this issue Jan 11, 2025 · 2 comments
Labels
bug Something isn't working needs:triage Issues that have not been investigated yet. scope:node Related to MSW running in Node

Comments

@Lord-Kamina
Copy link

Prerequisites

Environment check

  • I'm using the latest msw version
  • I'm using Node.js version 18 or higher

Node.js version

20.18.1

Reproduction repository

https://github.com/Lord-Kamina/always-upload-cache/tree/msw-issue

Reproduction steps

npm run test -- --runInBand --verbose --testLocationInResults=true --runTestsByPath tests/saveImpl.test.ts

Current behavior

The 'DELETE' requests sent by octokit are not being intercepted by MSW

Expected behavior

They should be intercepted? I really don't know what am I doing wrong.
What was virtually the same code was working in node16 using msw 0.49, you can see the working branch here: https://github.com/Lord-Kamina/always-upload-cache/tree/allow-refresh

@Lord-Kamina Lord-Kamina added bug Something isn't working needs:triage Issues that have not been investigated yet. scope:node Related to MSW running in Node labels Jan 11, 2025
@Lord-Kamina
Copy link
Author

Lord-Kamina commented Jan 27, 2025

Some more info... from this https://github.com/octokit/action.js/blob/49a9baa814345814970d410d61f5880a35e2cdf9/src/index.ts#L9, I gather this is related to #2165, but I didn't really understand how to fix it from what was described in that issue.

@kettanaito
Copy link
Member

@Lord-Kamina, thanks for opening this. Since Oktokit makes requests via unidici directly, those requests are not visible to MSW. We currently only support ClientRequest, XHR, and global fetch. Undici's request is a custom request implementation on top of net, which isn't supported by MSW at the moment.

We've done some preliminary work in https://github.com/mswjs/interceptors/releases/tag/v0.32.0, which now technically allows us to intercept raw net.Socket connections in Node.js. We still need to implement the actual interceptor, think how to reuse it in the ClientRequestInterceptor, and the publish it.

I've outlined the official proposal for this in mswjs/interceptors#707. I doubt I will find the time for it this year, but it always welcomes a thorough discussion first. I would be grateful for your input on it, if you have any. Thanks.

@github-actions github-actions bot locked and limited conversation to collaborators Feb 26, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working needs:triage Issues that have not been investigated yet. scope:node Related to MSW running in Node
Projects
None yet
Development

No branches or pull requests

2 participants