I am trying to upgrade my node-fetch with the instructions here: https://github.com/node-fetch/node-fetch/blob/HEAD/docs/v3-UPGRADE-GUIDE.md
I am able to get it to work and return a result when I don't set the signal option. I am not able to get the timeout working using timeoutSignal. https://github.com/node-fetch/timeout-signal
const signal = timeoutSignal(5000); // This returns and empty AbortSignal object
// setting this causes an error, the fetch works without it
_.set(
opts,
'signal',
signal
);
const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
fetchedResponse = await fetch(url, opts)
.then(response => {
console.log(response);
return response;
})
.catch(error => {
console.log(error);
})
If I change the property name 'signal' to anything else like 'signal-disable' or just remove it, everything works (without a timeout). The issue is that 'timeoutSignal(5000)' is returning an empty 'AbortSignal' object.
In the examples that I see, timeoutSignal seems to be always used in a client side scenario. I am not sure if this will work server side and can't find any examples.