Skip to content
Discussion options

You must be logged in to vote

createRetryStream is only availble inside the retry event handler - if its undefined, the retry event isnt firing. theres a few common reasons:

  1. you need to attach the retry listener BEFORE the stream starts
function openStream() {
  const stream = got.stream('https://stream.example.com', {
    retry: {
      limit: 5,
      methods: ['GET'],
      statusCodes: [408, 413, 429, 500, 502, 503, 504],
      errorCodes: ['ECONNRESET', 'ETIMEDOUT', 'ENOTFOUND']
    }
  });

  // Attach retry handler immediately
  stream.once('retry', (retryCount, error, createRetryStream) => {
    console.log(`Retrying (attempt ${retryCount}):`, error.code);
    
    // Clean up old stream first
    stream.des…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by sindresorhus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants