Skip to content
This repository has been archived by the owner on Jan 19, 2020. It is now read-only.

Error: Can't set headers after they are sent. #26

Closed
meetwudi opened this issue Oct 13, 2016 · 4 comments
Closed

Error: Can't set headers after they are sent. #26

meetwudi opened this issue Oct 13, 2016 · 4 comments

Comments

@meetwudi
Copy link
Contributor

I've deployed my messenger app the heroku, found following error for every messenger message event.

Also the messenger bot has a significant reply delay (1+hr) about 3 mins after setting subscription.

2016-10-13T17:29:13.499866+00:00 app[web.1]: Error: Can't set headers after they are sent.
2016-10-13T17:29:13.499871+00:00 app[web.1]:     at ServerResponse.contentType (/app/node_modules/express/lib/response.js:552:15)
2016-10-13T17:29:13.499872+00:00 app[web.1]:     at ServerResponse.sendStatus (/app/node_modules/express/lib/response.js:340:8)
2016-10-13T17:29:13.499872+00:00 app[web.1]:     at ServerResponse.res.success (/app/node_modules/bottr/lib/response-middleware.js:5:11)
2016-10-13T17:29:13.499873+00:00 app[web.1]:     at /app/node_modules/bottr/lib/facebook-messenger-client.js:64:15
2016-10-13T17:29:13.499874+00:00 app[web.1]:     at Array.forEach (native)
2016-10-13T17:29:13.499875+00:00 app[web.1]:     at /app/node_modules/bottr/lib/facebook-messenger-client.js:60:27
2016-10-13T17:29:13.499875+00:00 app[web.1]:     at Array.forEach (native)
2016-10-13T17:29:13.499876+00:00 app[web.1]:     at FacebookMessengerClient.handleEvent (/app/node_modules/bottr/lib/facebook-messenger-client.js:59:16)
2016-10-13T17:29:13.499877+00:00 app[web.1]:     at FacebookMessengerClient.<anonymous> (/app/node_modules/bottr/lib/facebook-messenger-client.js:35:12)
2016-10-13T17:29:13.499878+00:00 app[web.1]:     at Event.next (/app/node_modules/bottr/lib/event.js:16:14)
2016-10-13T17:29:13.499878+00:00 app[web.1]:     at EventEmitter.emit (/app/node_modules/bottr/lib/event-emitter.js:28:9)
2016-10-13T17:29:13.499879+00:00 app[web.1]:     at Bot.trigger (/app/node_modules/bottr/lib/bot.js:49:26)
2016-10-13T17:29:13.499880+00:00 app[web.1]:     at Bot.handleWebhookRequest (/app/node_modules/bottr/lib/bot.js:44:8)
2016-10-13T17:29:13.499880+00:00 app[web.1]:     at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
@jcampbell05
Copy link
Collaborator

Interesting, I believe I know the issue. I'll push a patch shortly.

@meetwudi
Copy link
Contributor Author

@jcampbell05 yeah I guess for .forEach is the issue. The later iterations might also send status code which raises the issue.

@jcampbell05
Copy link
Collaborator

Exactly 😀 just need to move the code to outside of that loop.

@jcampbell05
Copy link
Collaborator

@tjwudi Let me know if this fixes it for you.

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

No branches or pull requests

2 participants