Skip to content

How to send an early response and continue executing #3163

Answered by gregoryforel
gregoryforel asked this question in Q&A
Discussion options

You must be logged in to vote

@mikkelsvartveit sorry, I hadn't seen your question.

return streamSSE(c, async (stream) => {
  // Send early response to the client (Sveltekit needs to receive a response within 15 seconds)
  await stream.write(
    JSON.stringify({
      status: HttpStatusCode.Accepted,
    })
  );

  // Close the stream to send the response immediately  
  await stream.close();

  // ... rest of the processing continues ...
});

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@gregoryforel
Comment options

Comment options

You must be logged in to vote
1 reply
@mikkelsvartveit
Comment options

Comment options

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