Comments (11)
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.
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.
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.
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.
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.
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.
Please can you create a standalone repo with minimal dependencies that allows someone else to reproduce.
from sharp.
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.
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.
@Enngage @rnenjoy Are either of you able to create a minimal repo that allows someone else to reproduce?
from sharp.
@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)
- Using node js sharp package composite function is not giving an animated result HOT 4
- Issue with Color Consistency in CMYK Space When Using "Composite" in Sharp HOT 2
- Docs: add section with suggestions relating to security (includes relaxing defaults for trusted input) HOT 1
- When does one need to install `@img/sharp-libvips-dev`? HOT 1
- Strip EXIF data but keep original image unmodified HOT 2
- HELP, error in sharp. node js HOT 1
- How to set JFIF with jpg format HOT 2
- how to display tif image on the UI screen
- SharpJS not installing on Vercel anymore (it used to) HOT 1
- Get error "extract_area: bad extract area" when second extract call in toBuffer() HOT 2
- Install within Docker & PNPM HOT 3
- Error: Input buffer contains unsupported image format on image.metadata() HOT 2
- Width and height swapped in iOS photos HOT 5
- If packaging for cross platform electron, do I need to run npm install for both types of Mac CPU? HOT 1
- Support metadata for parsing gifs HOT 4
- vips jpegsave logs a warning while sharp handles it as error HOT 1
- Nuxt build failed on Cloudflare Pages. Cannot resolve "@img/sharp-wasm32/versions". HOT 2
- create gif using multiple images HOT 1
- Image metadata won't update HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sharp.