Giter Site home page Giter Site logo

Comments (11)

lovell avatar lovell commented on June 3, 2024

Nothing in the stack trace provided here is from within sharp itself.

If you still require help you'll need to provide some sample code that allows someone else to reproduce or at least better understand how you're trying to use sharp.

from sharp.

Enngage avatar Enngage commented on June 3, 2024

Thanks for a quick response.

Yeah, I know, it's minimized code (sorry). Sadly I can't get full trace from our deployed instance.

All calls to sharp fail, this is an example of one such instance:

import sharp from 'sharp';

// inputImage = Buffer

const webpImage = await sharp(inputImage)
    .webp({
	quality: 100,
	alphaQuality: 100,
	lossless: true,
})
.toBuffer();

The exception happens right here (I've added some logs right before & after the code above to be sure)

Nothing fancy. As I mentioned, it works perfectly fine locally, and in Azure on version 0.33.0. I did a test deploy by only changing 0.33.0 to 0.33.3 and this error started happening again. Changing back fixes it.

Really not sure what's going on and I'm fine with staying on older version, but figured I could post it here just in case others encounter(ed) same issue.

from sharp.

lovell avatar lovell commented on June 3, 2024

polyfills.server.mjs

My best guess would be that logic in your bundling step is erroneously polyfilling (i.e. monkey-patching) something fundamental, perhaps Object or Buffer.

Please can you try 0.33.1 and 0.33.2 to help narrow this down.

from sharp.

Enngage avatar Enngage commented on June 3, 2024

I don't think the bundling should be a problem here as it works with older versions. It's an Angular 17 SSR app (just FYI). This code is executed strictly on server (Node 20 - LTS on Linux).

I did several new releases one by one:

0.30.0 -> Works
0.30.1 -> Works
0.30.2 -> Works
0.30.3 -> Fails
Downgrade to 0.30.2 -> Works again

The only changes between these releases are sharp versions in package.json.

from sharp.

lovell avatar lovell commented on June 3, 2024

It's an Angular 17 SSR app... This code is executed strictly on server (Node 20 - LTS on Linux).

My best guess remains that something is being polyfilled in an unexpected or broken way. Can you prevent Angular from generating polyfills for the server side code? If not, what objects and functions are being polyfilled by dist/abc/server/polyfills.server.mjs?

Looking at the changes to sharp between v0.33.2 and v0.33.3 there is 7bc74fe that introduces the use of structuredClone, which is the sort of thing that I might imagine could be pollyfilled in a non-standard way.

from sharp.

rnenjoy avatar rnenjoy commented on June 3, 2024

Getting the same error on my apollo server.

await sharp(tmpFilePath) .resize({ width: 1500, height: 1500, fit: 'inside' }) .jpeg({ quality: 90 }) .toFile(tmpFileResizedPath)

both variables are paths /srv/http/blabla.jpg etc

error: TypeError: A string was expected at /srv/http/dev-net23/backend/node_modules/.pnpm/[email protected]/node_modules/sharp/lib/output.js:1534:15 at new Promise (<anonymous>) at Sharp._pipeline (/srv/http/dev-net23/backend/node_modules/.pnpm/[email protected]/node_modules/sharp/lib/output.js:1533:14) at Sharp.toFile (/srv/http/dev-net23/backend/node_modules/.pnpm/[email protected]/node_modules/sharp/lib/output.js:90:17) at Object.uploadAppWorkshopPicture (file:///srv/http/dev-net23/backend/src/modules/app/resolvers.js:35:6) { path: [ 'uploadAppWorkshopPicture' ], locations: [ { line: 2, column: 3 } ], extensions: [Object: null prototype] {}

from sharp.

lovell avatar lovell commented on June 3, 2024

Please can you create a standalone repo with minimal dependencies that allows someone else to reproduce.

from sharp.

rnenjoy avatar rnenjoy commented on June 3, 2024

Please can you create a standalone repo with minimal dependencies that allows someone else to reproduce.

Yes i will try to do that! I'm not that experienced in repos. Do i do that on github or some pastebin variant?

from sharp.

lovell avatar lovell commented on June 3, 2024

Do i do that on github

Yes please, that would be ideal, I'd expect to see a package.json file with dependencies, a single test image and a single JS file that someone else can use to reproduce.

from sharp.

lovell avatar lovell commented on June 3, 2024

@Enngage @rnenjoy Are either of you able to create a minimal repo that allows someone else to reproduce?

from sharp.

rnenjoy avatar rnenjoy commented on June 3, 2024

@Enngage @rnenjoy Are either of you able to create a minimal repo that allows someone else to reproduce?

Sorry for late reply. I was working on the minimal repo but didnt mange to get the error. Then i saw that i now used 0.33.4. And the problem seems to be gone? So no need to work any more on it? :)

from sharp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.