Browse Source

[bugfix] Fix write after end

B Thibault 8 years ago
parent
commit
e9eb9206ee
1 changed files with 6 additions and 3 deletions
  1. 6 3
      srv/src/httpServ.js

+ 6 - 3
srv/src/httpServ.js

@@ -117,14 +117,17 @@ Server.prototype.onRequest = function(req, res) {
                         res.writeHeader("403", {
                             "Content-Type": "application/json"
                         });
-                        res.write(slack.error);
+                        res.write(slack.error, () => {
+                            res.end();
+                        });
                     } else {
                         res.writeHeader("200", {
                             "Content-Type": "application/json"
                         });
-                        res.write(JSON.stringify(newData));
+                        res.write(JSON.stringify(newData), () => {
+                            res.end();
+                        });
                     }
-                    res.end();
                 } catch (e) {}
                 sessionManager.saveSession(req.session);
             });