Closed fend25 closed 11 years ago
I don't see anything wrong with this code. Can you create a dedicated test which illustrates the problem? It will be better if I run it and see the error.
There's no problem in the code. In pure nodejs@10.0.2
, using mongolian
and sync
this works right.
Problem not in code - it's in express' compatibility with pseudo-sync node.js (I think the point is in fibers-express compatibility)
@0ctave So, in windows I made a clean express project.
All dependencies are:
express@3.1.0
jade@0.28.2
sync@0.2.2
I used this exapmle:
https://github.com/0ctave/node-sync/blob/master/examples/express.js
So I wrote this app.js file:
https://gist.github.com/fend25/5293839
(it's almost original express app.js, just added require('sync')
and one router)
and for the first time it works (in browser I can see string "Hello Sync World!"), then it crashes with such log (full log of all app.js work):
C:\some_path\nodeapp>node app
Express server listening on port 3000
GET / 200 63ms - 170
GET /stylesheets/style.css 304 0ms
GET / 200 16ms - 170
GET /stylesheets/style.css 304 0ms
Error: Can't set headers after they are sent.
at ServerResponse.OutgoingMessage.setHeader (http.js:708:11)
at ServerResponse.res.setHeader (C:\some_path\nodeapp\node_modules\express\node_modules\connect\lib\patch.
js:59:22)
at next (C:\some_path\nodeapp\node_modules\express\node_modules\connect\lib\proto.js:162:13)
at pass (C:\some_path\nodeapp\node_modules\express\lib\router\index.js:107:24)
at nextRoute (C:\some_path\nodeapp\node_modules\express\lib\router\index.js:100:7)
at callbacks (C:\some_path\nodeapp\node_modules\express\lib\router\index.js:164:11)
at C:\some_path\nodeapp\node_modules\sync\lib\sync.js:412:38
at C:\some_path\nodeapp\node_modules\sync\lib\sync.js:190:13
at Function.SyncFiber [as Fiber] (C:\some_path\nodeapp\node_modules\sync\lib\sync.js:202:11)
at Sync (C:\some_path\nodeapp\node_modules\sync\lib\sync.js:89:21)
(null):0
(null)
C:\some_path\nodeapp>
P.S. may be the case in the windows?
Oh, $@#! On ubuntu 12.04 it works. (my gist from post below) Any ideas adout windows?
Sorry, but I can't support windows yet.
That's ok, I'll ask TJ about this. Thank you for the package.
in pure node.js this works perfect:
But the same code doesn't work in express app.Express falls like this:
Process finished with exit code -1073741819
@0ctave, do you know how to solve this?