Preview:
fastify.get('/unblock-event-loop', async (_request, reply) => {
  const hash = crypto.createHash('sha256');
  const numberOfHasUpdates = 10e6;

  const breathSpace = async delayInS =>
    new Promise(res => setTimeout(() => res(), delayInS * 1000));

  for (let iter = 0; iter < numberOfHasUpdates; iter++) {
    await hash.update(getRandomString());
    await breathSpace(0);
  }
  reply.send({ data: 'Finished long process' });
});
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter