1
0
Эх сурвалжийг харах

[bugfix] Fix write after end

B Thibault 8 жил өмнө
parent
commit
e9eb9206ee

+ 6 - 3
srv/src/httpServ.js

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