Skip to content

Commit c721d98

Browse files
committed
fix: wait for memory storage to write changes before Actor.exit exists the process
1 parent 99efba5 commit c721d98

File tree

3 files changed

+83
-54
lines changed

3 files changed

+83
-54
lines changed

package-lock.json

Lines changed: 67 additions & 51 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/apify/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@
5757
"@apify/consts": "^2.0.0",
5858
"@apify/log": "^2.1.0",
5959
"@apify/utilities": "^2.1.1",
60-
"@crawlee/core": "^3.0.0",
61-
"@crawlee/types": "^3.0.0",
62-
"@crawlee/utils": "^3.0.0",
60+
"@crawlee/core": "^3.0.2",
61+
"@crawlee/types": "^3.0.2",
62+
"@crawlee/utils": "^3.0.2",
6363
"semver": "^7.3.7",
6464
"apify-client": "^2.6.0",
6565
"ow": "^0.28.1",

packages/apify/src/actor.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,19 @@ export class Actor<Data extends Dictionary = Dictionary> {
206206
`Waiting for all event listeners to complete their execution timed out after ${options.timeoutSecs} seconds`,
207207
);
208208

209+
const client = this.config.getStorageClient();
210+
211+
if (client.teardown) {
212+
let finished = false;
213+
setTimeout(() => {
214+
if (!finished) {
215+
log.info('Waiting for the storage to write its state to file system.');
216+
}
217+
}, 1000);
218+
await client.teardown();
219+
finished = true;
220+
}
221+
209222
if (options.exitCode > 0) {
210223
options.statusMessage ??= `Actor finished with an error (exit code ${options.exitCode})`;
211224
log.error(options.statusMessage);

0 commit comments

Comments
 (0)