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
importhttpsfrom'https'import{Polly}from'@pollyjs/core'importNodeHttpAdapterfrom'@pollyjs/adapter-node-http'importInMemoryPersisterfrom'./in-memory-persister.js'functiondoRequest(){returnnewPromise(resolve=>{letdata=''constreq=https.request({host: 'echo.free.beeceptor.com',path: '/great-shot-kid',method: 'GET',// This is non-standard and has no effect on the requesthref: 'https://echo.free.beeceptor.com/these-are-not-the-droids-you-are-looking-for'},(res)=>{res.on('data',(chunk)=>{data+=chunk})res.on('end',()=>{constbody=JSON.parse(data)resolve(body.path)})})req.on('error',(e)=>{console.error(`problem with request: ${e.message}`);})req.end()})}console.log('Expected:')console.log(awaitdoRequest())Polly.register(NodeHttpAdapter)Polly.register(InMemoryPersister)constpolly=newPolly('node-http-test',{adapters: ['node-http'],persister: 'in-memory-persister',})console.log('\nActual:')console.log(awaitdoRequest())awaitpolly.stop()
Error Message & Stack Trace
N/A in this case. The request succeeds, it's just the wrong request.
Description
The use of the non-standard
href
property ingetUrlFromOptions
results in different behavior depending on whether or not Polly is enabled. There is no such property according to the Node.js documentation: https://nodejs.org/docs/latest-v18.x/api/http.html#httprequesturl-options-callbackUnfortunately there are libraries in the wild that use this non-standard property, and assign it an inconsistent/invalid value (I encounters this with the OpenSearch client library: https://github.com/opensearch-project/opensearch-js/blob/main/lib/Connection.js#L207)
Shareable Source
Error Message & Stack Trace
N/A in this case. The request succeeds, it's just the wrong request.
Config
Copy the config used to setup the Polly instance:
Dependencies
Copy the @pollyjs dependencies from
package.json
:Relevant Links
Environment
OS: darwin 23.6.0
Node.js v18.20.4
npm v10.7.0
The text was updated successfully, but these errors were encountered: