You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let me first say, I'm not sure if this is a bug exactly, but it did cause me a headache for an hour or two while I was trying to figure it out.
Reproducible By
const{ MockAgent }=require('undici')constundiciGlobalDispatcherSymbol=Symbol.for('undici.globalDispatcher.1')constundiciGlobalDispatcher=global[undiciGlobalDispatcherSymbol]if(!undiciGlobalDispatcher)thrownewError('Could not find the global Undici dispatcher')constmockAgent=newMockAgent();mockAgent.disableNetConnect();global[undiciGlobalDispatcherSymbol]=mockAgent;constpool=mockAgent.get("https://localhost");pool.intercept({path: "/api/some-path"}).reply(200,{ok: true});constres=awaitfetch(newURL("/api/some-path","https://localhost"));constdata=awaitres.json();console.log(data);// restoreglobal[undiciGlobalDispatcherSymbol]=undiciGlobalDispatcher;
Expected Behavior
Some kind of error or warning saying it's unexpected behaviour, or maybe just removing it for the user?
Logs & Screenshots
The above code will output:
TypeError: fetch failed
at node:internal/deps/undici/undici:13178:13
at async main (/home/local.epicure.ca/tyler.waters/code/GITHUB/undici-global-node-fetch-interceptor/index.js:19:17) {
[cause]: MockNotMatchedError: Mock dispatch not matched for path '/api/some-path': subsequent request to origin https://localhost was not allowed (net.connect disabled)
at MockPool.dispatch (/home/local.epicure.ca/tyler.waters/code/GITHUB/undici-global-node-fetch-interceptor/node_modules/undici/lib/mock/mock-utils.js:313:19)
at [dispatch] (/home/local.epicure.ca/tyler.waters/code/GITHUB/undici-global-node-fetch-interceptor/node_modules/undici/lib/dispatcher/agent.js:105:23)
at Intercept (/home/local.epicure.ca/tyler.waters/code/GITHUB/undici-global-node-fetch-interceptor/node_modules/undici/lib/interceptor/redirect-interceptor.js:11:16)
at [Intercepted Dispatch] (/home/local.epicure.ca/tyler.waters/code/GITHUB/undici-global-node-fetch-interceptor/node_modules/undici/lib/dispatcher/dispatcher-base.js:156:12)
at Agent.dispatch (/home/local.epicure.ca/tyler.waters/code/GITHUB/undici-global-node-fetch-interceptor/node_modules/undici/lib/dispatcher/dispatcher-base.js:177:40)
at MockAgent.dispatch (/home/local.epicure.ca/tyler.waters/code/GITHUB/undici-global-node-fetch-interceptor/node_modules/undici/lib/mock/mock-agent.js:55:25)
at node:internal/deps/undici/undici:10827:55
at new Promise (<anonymous>)
at dispatch (node:internal/deps/undici/undici:10827:16)
at httpNetworkFetch (node:internal/deps/undici/undici:10724:73) {
code: 'UND_MOCK_ERR_MOCK_NOT_MATCHED'
}
}
Bug Description
Let me first say, I'm not sure if this is a bug exactly, but it did cause me a headache for an hour or two while I was trying to figure it out.
Reproducible By
Expected Behavior
Some kind of error or warning saying it's unexpected behaviour, or maybe just removing it for the user?
Logs & Screenshots
The above code will output:
Removing the trailing slash results in:
Environment
The text was updated successfully, but these errors were encountered: