#503·pollyjs

PollyError: [Polly] Request failed due to an unknown error. TIMEOUT

Author: bschellingCreated Dec 9, 2024Updated Jan 27, 2025

Description

I'm unable to set the timeout correctly. Polly quits recording an URL which takes about 8 seconds to load with the message PollyError: [Polly] Request failed due to an unknown error.

I tried to set the timeout using the following code

 polly =   polly = new Polly(recordingName, {
    adapters: ['node-http'],
    persister: 'fs',
....
})

  const {server} = polly;
  server.timeout(15000);
  return polly;

Commenting out the following line in "@pollyjs/adapter-node-http/dist/cjs/pollyjs-adapter-node-http.js" fixes my problem, but that's obviously not the right thing to do....

javascript
    const responsePromise = new promise$1((resolve, reject) => {
      request.once('response', resolve);
      request.once('error', reject);
     // request.once('timeout', reject); -> it works if I comment out this line
    }); // Write the request body

Environment

Node.js v20.11.0
darwin 22.6.0
10.2.4
1.22.19