sharp icon indicating copy to clipboard operation
sharp copied to clipboard

Sharp randomly stalling when nesting sharp processes with composite

Open aletorrado opened this issue 3 years ago • 1 comments

Hi, I've noticed that some kind of race condition seems to happen when composing an image with another sharp instance, like this:

let outer = sharp(....)
outer.composite([
  await sharp(....)
  .toBuffer()
])
await outer.toBuffer()

Please notice that the outer sharp instance is first instantiated but not finalized, and the inner sharp instance runs between instantiation and finalization.

This way, the process randomly stalls, having the nested promise to return (the inner image), but not the outer one. I'm using the latest 0.30.7 version of sharp, and node v18.8.0.

I've fixed this reliably by moving the inner image processing before instantiation, like this:

let inner = await sharp(....).toBuffer()
let outer = sharp(....)
outer.composite([
  inner
])
await outer.toBuffer()

Is this bug known? Please let me know if I can help somehow.

Thanks

aletorrado avatar Aug 26 '22 14:08 aletorrado

Please can you provide complete, standalone code that allows someone else to reproduce.

lovell avatar Aug 27 '22 08:08 lovell

Closing due to inactivity but please feel free to reopen with the requested details if further help is required.

lovell avatar Sep 27 '22 13:09 lovell