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

Run next() after successfully sending data to the client #2338

Merged
merged 1 commit into from
Jul 20, 2016
Merged

Run next() after successfully sending data to the client #2338

merged 1 commit into from
Jul 20, 2016

Conversation

blacha
Copy link
Contributor

@blacha blacha commented Jul 20, 2016

This allows developers to add express handlers for successful completion of parse-server requests.

ie Analytics or Logging.

This allows developers to add express handlers for successful completion of parse-server requests.
ie Analytics or Logging.
@tillifywebb
Copy link

We are getting following errors from this pull

at Layer.handle as handle_request
at jsonParser (/bundle/node_modules/parse-server/node_modules/body-parser/lib/types/json.js:94:7)
at next (/bundle/node_modules/express/lib/router/index.js:271:10)
at Function.process_params (/bundle/node_modules/express/lib/router/index.js:330:12)
at /bundle/node_modules/express/lib/router/index.js:280:7
at trim_prefix (/bundle/node_modules/express/lib/router/index.js:312:13)
at Layer.handle as handle_request
at allowCrossDomain (/bundle/index.js:439:9)
at ServerResponse.header (/bundle/node_modules/express/lib/response.js:719:10)
at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:344:11)
Error: Can't set headers after they are sent.

Not sure what we are doing wrong.

If we make any cloud function calls we get the error. We have remove our app.js require in our main.js code to test if a module, express code is causing issue. This did not change anything.

@sprabs
Copy link

sprabs commented Jul 26, 2016

Yeah, this needs to be revisited. It appears to have caused errors in Cloud Code method calls for a large number of us, even when they are no issues with the call and it returns the right data.

@blacha Could you please take a look? When I revert your change in my local repo, it's fine.

@blacha
Copy link
Contributor Author

blacha commented Jul 26, 2016

@sprabs When running this locally and in production across a bunch of different cloud functions I have no issues at all.

What sort of system setup do you use?

That error generally implies something else has been run after data has been sent back to the client. If you have a setup express yourself make sure you don't have any app.use setup after app.use('/parse', ParseSeverInstance);

Another option would be if you have code that runs both success and error handlers.

response.success() 
response.error()

@woodardj
Copy link

Yes, I'm seeing the same issue as @tillifywebb -- It appears that after a call to /parse/classes/:className, express is falling through into the auth middleware I'm mounting after the parse server instance, where I'm then getting this error.

@tillifywebb
Copy link

I tired removing the express setup - and I still got the error, that was on nodechef just running a simple SP that queries the DB, we have since rolled back as it was causing issues.

rsouzas pushed a commit to back4app/parse-server that referenced this pull request Mar 15, 2017
…nity#2338)

This allows developers to add express handlers for successful completion of parse-server requests.
ie Analytics or Logging.
rsouzas pushed a commit to back4app/parse-server that referenced this pull request Mar 16, 2017
…nity#2338)

This allows developers to add express handlers for successful completion of parse-server requests.
ie Analytics or Logging.
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 this pull request may close these issues.

None yet

5 participants