-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use express-session with nest/graphql #4527
Comments
I'm getting this error too. Scott |
Same here. It's a shame because it works great with REST :/ |
This is the Apollo Server repository. This issue appears to be reporting a bug in combining something called It looks like |
I'm submitting a...
Current behavior
Currently I created simple boilerplate of nestjs/graphql with express-session middleware. I hooked session middleware in main.ts file. with saveUninitialized flag true... my nestjs server breaks with following error
(node:67816) UnhandledPromiseRejectionWarning: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client at ServerResponse.setHeader (_http_outgoing.js:485:11).
Also when I tries to create session on server by using ctx.req.session.userId. same error occur I find similar issue on github
issue link. But I am unaware how to do it in nestjs fashion. I am new with nestjs.
Expected behavior
Minimal reproduction of the problem with instructions
app.use(session({ name: SESSION_NAME, store: new RedisStore({ host:REDIS_HOST, port:REDIS_PORT, client: client, disableTouch: true, }), cookie: { maxAge: 1000 * 60 * 60 * 24 * 365 * 10, // 10 years httpOnly: true, sameSite: "lax", // csrf secure: __PROD__, // cookie only works in https domain: __PROD__ ? ".local" : undefined, }, saveUninitialized: true, secret: SESSION_SECRET, resave: true }))
What is the motivation / use case for changing the behavior?
(node:45556) UnhandledPromiseRejectionWarning: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client at ServerResponse.setHeader (_http_outgoing.js:485:11) at ServerResponse.header (C:\Users\gaura\Desktop\Teaching Ninjas\server\node_modules\express\lib\response.js:771:10) at ServerResponse.send (C:\Users\gaura\Desktop\Teaching Ninjas\server\node_modules\express\lib\response.js:170:12) at ServerResponse.json (C:\Users\gaura\Desktop\Teaching Ninjas\server\node_modules\express\lib\response.js:267:15) at ExpressAdapter.reply (C:\Users\gaura\Desktop\Teaching Ninjas\server\node_modules\@nestjs\platform-express\adapters\express-adapter.js:24:57) at ExceptionsHandler.handleUnknownError (C:\Users\gaura\Desktop\Teaching Ninjas\server\node_modules\@nestjs\core\exceptions\base-exception-filter.js:33:24) at ExceptionsHandler.catch (C:\Users\gaura\Desktop\Teaching Ninjas\server\node_modules\@nestjs\core\exceptions\base-exception-filter.js:17:25) at ExceptionsHandler.next (C:\Users\gaura\Desktop\Teaching Ninjas\server\node_modules\@nestjs\core\exceptions\exceptions-handler.js:16:20) at C:\Users\gaura\Desktop\Teaching Ninjas\server\node_modules\@nestjs\core\router\router-proxy.js:24:35 at Layer.handle_error (C:\Users\gaura\Desktop\Teaching Ninjas\server\node_modules\express\lib\router\layer.js:71:5) at trim_prefix (C:\Users\gaura\Desktop\Teaching Ninjas\server\node_modules\express\lib\router\index.js:315:13) at C:\Users\gaura\Desktop\Teaching Ninjas\server\node_modules\express\lib\router\index.js:284:7 at Function.process_params (C:\Users\gaura\Desktop\Teaching Ninjas\server\node_modules\express\lib\router\index.js:335:12) at next (C:\Users\gaura\Desktop\Teaching Ninjas\server\node_modules\express\lib\router\index.js:275:10) at Layer.handle_error (C:\Users\gaura\Desktop\Teaching Ninjas\server\node_modules\express\lib\router\layer.js:67:12) at trim_prefix (C:\Users\gaura\Desktop\Teaching Ninjas\server\node_modules\express\lib\router\index.js:315:13) at C:\Users\gaura\Desktop\Teaching Ninjas\server\node_modules\express\lib\router\index.js:284:7 at Function.process_params (C:\Users\gaura\Desktop\Teaching Ninjas\server\node_modules\express\lib\router\index.js:335:12) at Immediate.next [as _onImmediate] (C:\Users\gaura\Desktop\Teaching Ninjas\server\node_modules\express\lib\router\index.js:275:10) at processImmediate (internal/timers.js:441:21) (node:45556) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:45556) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code
The text was updated successfully, but these errors were encountered: