zapier-platform-core 9.7.2 → 9.7.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 +2 -2
- package/src/tools/create-logger.js +13 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zapier-platform-core",
|
|
3
|
-
"version": "9.7.
|
|
3
|
+
"version": "9.7.3",
|
|
4
4
|
"description": "The core SDK for CLI apps in the Zapier Developer Platform.",
|
|
5
5
|
"repository": "zapier/zapier-platform-core",
|
|
6
6
|
"homepage": "https://zapier.com/",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"node-fetch": "2.6.7",
|
|
48
48
|
"oauth-sign": "0.9.0",
|
|
49
49
|
"semver": "5.6.0",
|
|
50
|
-
"zapier-platform-schema": "9.7.
|
|
50
|
+
"zapier-platform-schema": "9.7.3"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"adm-zip": "0.4.13",
|
|
@@ -172,6 +172,7 @@ class LogStream extends Transform {
|
|
|
172
172
|
class LogStreamFactory {
|
|
173
173
|
constructor() {
|
|
174
174
|
this._logStream = null;
|
|
175
|
+
this.ended = false;
|
|
175
176
|
}
|
|
176
177
|
|
|
177
178
|
getOrCreate(url, token) {
|
|
@@ -190,6 +191,10 @@ class LogStreamFactory {
|
|
|
190
191
|
}
|
|
191
192
|
|
|
192
193
|
async end() {
|
|
194
|
+
// Mark the factory as ended. This suggests that any logStream.write() that
|
|
195
|
+
// follows should end() right away.
|
|
196
|
+
this.ended = true;
|
|
197
|
+
|
|
193
198
|
if (this._logStream) {
|
|
194
199
|
this._logStream.end();
|
|
195
200
|
const response = await this._logStream.request;
|
|
@@ -245,6 +250,14 @@ const sendLog = async (logStreamFactory, options, event, message, data) => {
|
|
|
245
250
|
// no line breaks, and after an object it ends with a line break.
|
|
246
251
|
JSON.stringify({ message: safeMessage, data: safeData }) + '\n'
|
|
247
252
|
);
|
|
253
|
+
|
|
254
|
+
if (logStreamFactory.ended) {
|
|
255
|
+
// Lambda handler calls logger.end() at the end. But what if there's a
|
|
256
|
+
// (bad) callback that is still running after the Lambda handler returns?
|
|
257
|
+
// We need to make sure the bad callback ends the logger as well.
|
|
258
|
+
// Otherwise, it will hang!
|
|
259
|
+
logStreamFactory.end();
|
|
260
|
+
}
|
|
248
261
|
}
|
|
249
262
|
};
|
|
250
263
|
|