Comments (16)
Is it possible to provide a full test app I can run to reproduce the issue? That way I can attach a debugger to see what's happening. Otherwise, you're welcome to make a PR :)
from cookie-session.
I will whip up a failing test.
from cookie-session.
Cool, also would be helpful if you provided the following version in the meantime to help me work in parallel: version of Node.js, version of express flash, version of this module.
from cookie-session.
Forked this project and wrote an integration test using connect-flash:
https://github.com/zbyte64/cookie-session/blob/flash-message-fail/test/flash_test.js
I think I made some mistake because I can see in the view that properly retrieves the prior flash messages but weird stuff happens when I try to send it back to the client (empty response when sending a non-empty string, 500 if I don't stringify).
The package.json of the project experiencing the issue: https://github.com/zbyte64/project-cms-backend/blob/postgres/package.json ; using node v6.4
from cookie-session.
I'm not seeing any issue with this module in your test, unless I'm missing something?
from cookie-session.
The test fails:
1) Cookie Session with flash message should persist:
Uncaught AssertionError: {} deepEqual { info: [ 'hello world' ] }
+ expected - actual
-{}
+{
+ "info": [
+ "hello world"
+ ]
+}
from cookie-session.
Yea, but res.body
has nothing to do with this module. What if you move the assert into the server side and test what is in req.session
?
from cookie-session.
If you can please put together a pull request with a potential fix to this module, that would probably be ideal, because I'm not sure I see any issue based on that test, but again, I may be missing something :(
from cookie-session.
You're right, this is an issue outside of cookie-session (connect?).
from cookie-session.
So to add, I had to heavily modify your test just to get it to run for me. Just cloning it, npm install
+ npm test
gave me the following error:
$ npm test
> [email protected] test C:\cs-test\cookie-session
> mocha --check-leaks --reporter spec --bail test/
Cookie Session with flash message
1) should Set-Cookie
0 passing (25ms)
1 failing
1) Cookie Session with flash message should Set-Cookie:
Uncaught TypeError: Cannot read property 'header' of undefined
at Test.<anonymous> (C:\cs-test\cookie-session\test\flash_test.js:25:21)
at Test.assert (C:\cs-test\cookie-session\node_modules\supertest\lib\test.js:156:6)
at Server.assert (C:\cs-test\cookie-session\node_modules\supertest\lib\test.js:127:12)
at net.js:1277:10
npm ERR! Test failed. See above for more details.
from cookie-session.
On https://github.com/jaredhanson/connect-flash I only see mentions about using it on Express 3.x. Are you sure it even works on Connect?
from cookie-session.
Hmm, title does mention connect at the top, but given it hasn't been updated in 4 years....
(Flash message middleware for Connect and Express.
)
from cookie-session.
@zbyte64 does it sound like you are experiencing this bug? jaredhanson/connect-flash#22
from cookie-session.
Possibly, but not even error
type is working for me.
from cookie-session.
Hi @zbyte64 your test you have above passes without issue if you add res.setHeader('Content-Type', 'application/json');
between lines 38 and 39. The reason your req.body
was {}
is because supertest
didn't know it was JSON to parse without a Content-Type
header.
from cookie-session.
Thank you.
I ended up using req-flash
( maximilianschmitt/req-flash ) and it works.
from cookie-session.
Related Issues (20)
- Cookies aren't sent if secure flag set previously HOT 7
- Session does not get stored if keys is not an array HOT 3
- What am I doing wrong? [question] HOT 1
- Clearing session does not remove cookies HOT 8
- Generating unique session.sig after logout/login HOT 3
- Use cookie-session as non middleware HOT 2
- Not working with axios (chrome) but working with Postman HOT 10
- Document: Ambiguity in Signature Documentation HOT 4
- sameSite no longer defaults to 'None' when undefined HOT 4
- session cookie value is exceedingly long and fails Set-Cookie with invalid syntax HOT 2
- secureProxy option to be able to use with non-Express servers behind SSL proxy HOT 1
- Suggestion: a custom name instead of req.session HOT 2
- Update dependency from [email protected] to [email protected] HOT 3
- Is there a risk when someone modifies the userId in the cookie? HOT 2
- Session cookie not sent over from server when using Firefox HOT 4
- Problem using with passport 0.6.0: session.regenerate is not a function HOT 7
- flag Priority=High
- encrypt cookies
- The link to a list of browser cookie limits is dead
- Larger cookies with compression
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 cookie-session.