sst 2.10.2 → 2.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/support/nodejs-runtime/index.mjs +23 -19
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@ var file = [".js", ".jsx", ".mjs", ".cjs"].map((ext) => path.join(input.out, par
|
|
|
14
14
|
var fn;
|
|
15
15
|
function fetch(req) {
|
|
16
16
|
return new Promise((resolve, reject) => {
|
|
17
|
-
const
|
|
17
|
+
const request2 = http.request(
|
|
18
18
|
input.url + req.path,
|
|
19
19
|
{
|
|
20
20
|
headers: req.headers,
|
|
@@ -35,10 +35,10 @@ function fetch(req) {
|
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
);
|
|
38
|
-
|
|
38
|
+
request2.on("error", reject);
|
|
39
39
|
if (req.body)
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
request2.write(req.body);
|
|
41
|
+
request2.end();
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
try {
|
|
@@ -67,15 +67,30 @@ try {
|
|
|
67
67
|
process.exit(1);
|
|
68
68
|
}
|
|
69
69
|
var timeout;
|
|
70
|
+
var request;
|
|
71
|
+
var response;
|
|
72
|
+
var context;
|
|
73
|
+
async function error(ex) {
|
|
74
|
+
await fetch({
|
|
75
|
+
path: `/runtime/invocation/${context.awsRequestId}/error`,
|
|
76
|
+
method: "POST",
|
|
77
|
+
headers: {
|
|
78
|
+
"Content-Type": "application/json"
|
|
79
|
+
},
|
|
80
|
+
body: JSON.stringify({
|
|
81
|
+
errorType: "Error",
|
|
82
|
+
errorMessage: ex.message,
|
|
83
|
+
trace: ex.stack?.split("\n")
|
|
84
|
+
})
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
process.on("unhandledRejection", error);
|
|
70
88
|
while (true) {
|
|
71
89
|
if (timeout)
|
|
72
90
|
clearTimeout(timeout);
|
|
73
91
|
timeout = setTimeout(() => {
|
|
74
92
|
process.exit(0);
|
|
75
93
|
}, 1e3 * 60 * 15);
|
|
76
|
-
let request;
|
|
77
|
-
let response;
|
|
78
|
-
let context;
|
|
79
94
|
try {
|
|
80
95
|
const result = await fetch({
|
|
81
96
|
path: `/runtime/invocation/next`,
|
|
@@ -130,18 +145,7 @@ while (true) {
|
|
|
130
145
|
try {
|
|
131
146
|
response = await fn(request, context);
|
|
132
147
|
} catch (ex) {
|
|
133
|
-
|
|
134
|
-
path: `/runtime/invocation/${context.awsRequestId}/error`,
|
|
135
|
-
method: "POST",
|
|
136
|
-
headers: {
|
|
137
|
-
"Content-Type": "application/json"
|
|
138
|
-
},
|
|
139
|
-
body: JSON.stringify({
|
|
140
|
-
errorType: "Error",
|
|
141
|
-
errorMessage: ex.message,
|
|
142
|
-
trace: ex.stack?.split("\n")
|
|
143
|
-
})
|
|
144
|
-
});
|
|
148
|
+
error(ex);
|
|
145
149
|
continue;
|
|
146
150
|
}
|
|
147
151
|
while (true) {
|