Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit506bad7

Browse files
committed
fix(connect): close server correctly
1 parent95025c6 commit506bad7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

‎src/connect/connect-echo-example.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use strict";
22
importconnectfrom"connect";
33
importhttpfrom"http";
4+
importfetchfrom"node-fetch";
45
importassertfrom"assert";
56
varapp=connect();
67
// add Error handling
@@ -16,6 +17,7 @@ app.use(function (req, res) {
1617
//create node.js http server and listen on port
1718
varserver=http.createServer(app).listen(3000,request);
1819

20+
varcloseServer=server.close.bind(server);
1921
// request => response
2022
functionrequest(){
2123
varrequestBody={
@@ -28,6 +30,5 @@ function request() {
2830
.then(res=>res.text())
2931
.then(text=>{
3032
assert.deepEqual(text,requestBody);
31-
server.close();
32-
}).catch(console.error.bind(console));
33+
}).then(closeServer,closeServer);
3334
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp