Comments (3)
with node server.js everything works fine. but when I run it with bun server.js it got stuck on line const result = await s3.send(command); when I send a request from Postman. I can see the command log but cannot see the done log.
Is the uploadImage
function being await
'?
Otherwise, this mostly appears to be a formatting difference between Bun and Node for Buffer
objects and potentially classes as well
Via @mangs in the discord: https://discord.com/channels/876711213126520882/1149339379446325248/1218435079802716221
mangs — Today at 10:46 PM
those outputs are the same, convert decimal to hex and you get the same values
https://www.binaryhexconverter.com/decimal-to-hex-converter
In the future please use code blocks on GitHub to format your code, it's difficult to see what you mean exactly
from bun.
Yes, I am awaiting the uploadImage function. the same code is working when I run with node
but stuck on const result = await s3.send(command);
when I run this using Bun
here is my code.
// -----------------------------------------------------------
// imports
// -----------------------------------------------------------
const sharp = require('sharp');
const {
S3Client,
PutObjectCommand,
DeleteObjectCommand,
} = require('@aws-sdk/client-s3');
const AppError = require('../utils/appError');
// -----------------------------------------------------------
// configurations
// -----------------------------------------------------------
const s3 = new S3Client({
credentials: {
accessKeyId: process.env.AWS_ACCESS_KEY,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
},
region: process.env.AWS_REGION,
});
// -----------------------------------------------------------
// exports
// -----------------------------------------------------------
exports.uploadImage = async (path, name, next) => {
const fileBuffer = await sharp(path).toBuffer();
const params = {
Body: fileBuffer,
Bucket: process.env.AWS_BUCKET_NAME,
ContentType: 'image/jpeg',
Key: name,
};
// Uploading files to the bucket
const command = new PutObjectCommand(params);
const result = await s3.send(command);
if (result.$metadata.httpStatusCode !== 200) {
return next(new AppError('Image update failed', 500));
}
const url = `https://${process.env.AWS_BUCKET_NAME}.s3.${process.env.AWS_REGION}.amazonaws.com/${name}`;
return url;
};
exports.deleteImage = async (Key) => {
const params = {
Bucket: process.env.AWS_BUCKET_NAME,
Key,
};
const command = new DeleteObjectCommand(params);
const result = await s3.send(command);
return result;
};
from bun.
@Jarred-Sumner I am still struggling to figure out what's wrong. The same code works for node
but not for bun
.
a few screenshots to understand
from bun.
Related Issues (20)
- Workers sometimes don't ref the event loop.
- Version 1.0.32 broke Eslint setup HOT 12
- Labeler tool: layout shift showing steps
- "incorrect alignment" leads to crash HOT 3
- function createBrotliDecompress is present when Brotli isn't supported HOT 2
- `bun install` on macos creates a cache named `~` in the current directory HOT 3
- bun test --watch --only has unexpected behavior HOT 1
- Attempting to install prisma results in a incorrect alignment error
- bunx Error: Cannot find module HOT 2
- Investigate dumping invalid unicode in bunshell.test
- Add CPU usage test for `bun install` when waiting for lifecycle scripts that do nothing
- bun install failed on `>=v1.0.32` while success on `v1.0.31` HOT 4
- Why can't import some packages from npm? HOT 1
- [WebSocket] chrome-remote-interface working in Node, but not Bun
- Improve error message when using non-`file:` URLs in `Bun.file` HOT 1
- No result when running prisma generate with bun HOT 1
- Shell pipe regression HOT 1
- musl build HOT 1
- Slim Docker images without all locales HOT 2
- Intermittent Errors with `Bun.build` and `Bun.FileSystemRouter` when importing absolute paths
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 bun.