Skip to content
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

next() function not called in middleware, which breaks express-http-context (cls-hooked) #1046

Open
kr99 opened this issue Nov 11, 2021 · 3 comments · May be fixed by #1124
Open

next() function not called in middleware, which breaks express-http-context (cls-hooked) #1046

kr99 opened this issue Nov 11, 2021 · 3 comments · May be fixed by #1124

Comments

@kr99
Copy link

kr99 commented Nov 11, 2021

req.pipe(busboy)

The last line in the function should be a call to next() (right after the line shown)

When I do roughly something like this...

const httpContext = require('express-http-context')
app.use(httpContext.middleware)
app.use(() => {httpContext.set('thing', 'value')})
...
router.put('/', upload.single('file'), myFunction)
...
inside myFunction():
httpContext.get('thing') // undefined, but only when there's a 'file' param in the multipart form...
@dougwilson
Copy link
Contributor

Of course if there was a next() call at that location, then your myFunction would never have access to any uploaded files, as busboy would not have the opportunity to recieve the request data and parse the form.

@kr99
Copy link
Author

kr99 commented Nov 11, 2021

That's fair--I don't understand what exactly is happening here I guess. Any pointers or suggestions @dougwilson ? Thanks for your time.

@dougwilson
Copy link
Contributor

I'm not familiar with that context module and what it is doing to keep the state around. Have you opened an issue in their repo about the state being lost? It seems to be a pretty common issue opened there and I didn't see any regarding multer. If you or that module's author can provide some kind of PR or specific guidence on what to change in multer that would be a big help. It is also possible that it is just a change in that module, but that module's author would know better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants