oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.54k stars 2.78k forks source link

In Postman, shows Parse Error: The server returned a malformed response #7708

Open Talha76 opened 11 months ago

Talha76 commented 11 months ago

What version of Bun is running?

1.0.16+800fb1290

What platform is your computer?

Linux 5.15.0-91-generic x86_64 x86_64

What steps can reproduce the bug?

When I make a request from postman on the server running with bun, it gives me the following error, (I execute bun start to start sever with bun run index.js): image But when I run the server with npm, and I make a request to the same URL, it gives the expected output. I execute bun dev to start server with script: nodemon index.js: image

To reproduce the bug,

  1. Start a server.
  2. Make a request to a valid endpoint in postman.

What is the expected behavior?

No response

What do you see instead?

No response

Additional information

Here is my package.json:

{
  "name": "cp-project",
  "version": "1.0.0",
  "description": "To install dependencies:",
  "main": "index.js",
  "scripts": {
    "dev": "nodemon index.js",
    "start": "bun run --watch index.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "bcryptjs": "^2.4.3",
    "body-parser": "^1.20.2",
    "dotenv": "^16.3.1",
    "express": "^4.18.2",
    "express-session": "^1.17.3",
    "mongoose": "^8.0.3",
    "multer": "^1.4.5-lts.1",
    "passport": "^0.7.0",
    "passport-local": "^1.0.0"
  },
  "devDependencies": {
    "nodemon": "^3.0.2"
  }
}
Talha76 commented 11 months ago

Update: As far I understood, this issue occured due to the following code:

app.use(session({
  secret: "secret",
  resave: true,
  saveUninitialized: true // mainly due to this
}));

But when I recoded saveUninitialized: false, this issue was removed, I don't know why.

VigilioYonatan commented 10 months ago

any update?

Talha76 commented 10 months ago

@VigilioYonatan Same issue persists. But I can't find out the exact reason.

Primexz commented 10 months ago

A cool way to reproduce this issue:

const app = require('express')();
const session = require('express-session');

app.get('/', (req, res) => {
    res.send("cool")
});

app.use(session({
    secret: "asdasd"
}))

app.get('/test', (req, res) => {
    res.send("cool")
})

app.listen(3000, () => {
    console.log('Server is running on port 3000');
})

127.0.0.1:3000/ will work 127.0.0.1:3000/test will not work

Starboy667 commented 9 months ago

Any update?

cheong12001 commented 9 months ago

I encounter the same issue and no solve so far. The problem only occurs in Postman but not in curl.

castorfelipe commented 8 months ago

Same problem here, I'm using express and express-session. Oh god, please help me