Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

mojito crash when page is reloaded and a mojit invoke() is in progress #1374

Open
jithine opened this issue May 7, 2014 · 1 comment
Open

Comments

@jithine
Copy link

jithine commented May 7, 2014

Sequence -

  1. User does a page action which does a mojit invoke()
  2. Before invoke() is processed user does browser refresh
  3. Mojito crashes

Log is captured from the moment user clicks page refresh. 1st part shows that express is detecting a request abort, but in last part of the log, the mojit's controller calls ac.done() and crashes. This is the controller action which was invoked before user did page refresh.

debug: (mojito-dispatcher): Dispatcher created
info: serving locales from cache
Error: Request aborted
    at IncomingMessage.onReqAborted (/home/jithine/g11n_self_serve/node_modules/express/node_modules/connect/node_modules/multiparty/index.js:131:17)
    at IncomingMessage.EventEmitter.emit (events.js:92:17)
    at abortIncoming (http.js:1912:11)
    at Socket.socket.onend (http.js:2004:7)
    at Socket.g (events.js:175:14)
    at Socket.EventEmitter.emit (events.js:117:20)
    at _stream_readable.js:920:16
    at process._tickCallback (node.js:419:13)
debug: (mojito-dispatcher): Dispatcher created
info: (outputhandler.server): done

Error: Can't set headers after they are sent.
    at ServerResponse.OutgoingMessage.setHeader (http.js:692:11)
    at ServerResponse.res.setHeader (/home/jithine/g11n_self_serve/node_modules/express/node_modules/connect/lib/patch.js:63:22)
    at ServerResponse.<anonymous> (/home/jithine/g11n_self_serve/node_modules/express/node_modules/connect/lib/patch.js:80:14)
    at Array.forEach (native)
    at ServerResponse.res.writeHead (/home/jithine/g11n_self_serve/node_modules/express/node_modules/connect/lib/patch.js:79:28)
    at Object.OutputHandler._writeHeaders (/home/jithine/g11n_self_serve/node_modules/mojito/lib/output-handler.server.js:133:26)
    at Object.OutputHandler.done (/home/jithine/g11n_self_serve/node_modules/mojito/lib/output-handler.server.js:59:14)
    at Object.ActionContext.done (/home/jithine/g11n_self_serve/node_modules/mojito/lib/app/autoload/action-context.common.js:532:38)
    at /home/jithine/g11n_self_serve/mojits/TaskList/controller.server.js:386:20
    at /home/jithine/g11n_self_serve/mojits/TaskList/models/model.server.js:80:21
ss [jithine@firedesire g11n_self_serve]$
@aljimenez
Copy link
Contributor

Seems like _writeHeaders is getting called after the res object has been closed: (https://github.com/yahoo/mojito/blob/0d36bf1bbe9b851f34eaca1490886a52ec1f9818/lib/output-handler.server.js#L125)

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