Vercel API: Get Deployment Events Never Done

I am streaming response from the deployment events endpoint:

https://api.vercel.com/v3/deployments/{urlOrId}/events?limit=-1&follow=1

CURRENT BEHAVIOR

Reading the response, never receives “done”. The request stays open even after the deployment has finished.

EXPECTED BEHAVIOR

When the deployment is finished, the server should close the readable stream.

  const response = await fetch(
    `https://api.vercel.com/v3/deployments/${urlOrId}/events?limit=-1&follow=1`,
    {
      headers: {
        Authorization: `Bearer ${token}`,
      },
    },
  );

  const reader = response.body?.getReader();

  if (reader) {
    while (true) {
      const { done, value } = await reader.read();
      if (done) {
        // TODO: never happens?
        break;
      }
      const next = new TextDecoder().decode(value);
      setText((prev) => prev + next);
    }
  }


NextJS 15, React 19, deployed on Vercel and occurs in all environments development/preview/production

Hey @ybot1122! The behavior of the “get deployment events” endpoint changes based on the params.

It can work as an infinite stream of logs or as a JSON endpoint depending on the input parameters.

In your example, the query ?limit=-1&follow=1 is keeping the stream open. :slightly_smiling_face:

1 Like

Oh I see, infinite stream is the expected behavior.

I have chosen to move forward by polling the deployment events endpoint until deployment state is done.

Thank you for the reply!

2 Likes