Skip to content

DecompressionStream generates unhandled rejections #6061

@ChALkeR

Description

@ChALkeR

This is different from #6020: that one is about firing the unhandledrejection event too early for rejections that get handled, this one is about a scenario where leaking rejections don't ever get handled.

For example on the testcase from nodejs/node#58247:

  const useFrom = Array.fromAsync // switch to false and it works

  let c = 0
  globalThis.addEventListener('rejectionhandled', (e) => {
    console.log('rejections', --c)
  })
  globalThis.addEventListener('unhandledrejection', (e) => {
    console.log('rejections', ++c)
  })

  const valid = new Uint8Array([120, 156, 75, 4, 0, 0, 98, 0, 98]) // deflate('a')
  const empty = new Uint8Array(1)
  const invalid = new Uint8Array([...valid, ...empty])
  const double = new Uint8Array([...valid, ...valid])
  for (const chunks of [[valid], [invalid], [valid, empty], [valid, valid], [double]]) {
    try {
      const stream = new Blob(chunks).stream().pipeThrough(new DecompressionStream('deflate'))
      console.log(await (useFrom ? Array.fromAsync(stream) : new Response(stream).blob()))
    } catch (e) {
      console.error(e)
    }
  }

  await new Promise((resolve) => setTimeout(resolve, 200))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions