crawlee: The database connection is not open

Describe the bug We just upgraded from 0.21.4 to 0.22.4. Now, we sometimes get a The database connection is not open when executing after the queue finishes:

const requestQueue = await Apify.openRequestQueue('some-queue-name');

Here is an example log output:

INFO  CheerioCrawler: All the requests from request list and/or request queue have been processed, the crawler will shut down.

INFO  CheerioCrawler: Final request statistics: {"requestsFinished":6464,"requestsFailed":0,"retryHistogram":[6464],"requestAvgFailedDurationMillis":null,"requestAvgFinishedDurationMillis":520,"requestsFinishedPerMinute":1035,"requestsFailedPerMinute":0,"requestTotalDurationMillis":3359734,"requestsTotal":6464,"crawlerRuntimeMillis":374896}

TypeError: The database connection is not open

Here’s the full stack trace:

TypeError: The database connection is not open
  File "/home/****-crawler/releases/20210114184826/node_modules/@apify/storage-local/src/emulators/request_queue_emulator.js", line 373, col 17, in RequestQueueEmulator._createTables
    this.db.prepare(`
  File "/home/****-crawler/releases/20210114184826/node_modules/@apify/storage-local/src/emulators/request_queue_emulator.js", line 37, col 14, in new RequestQueueEmulator
    this._createTables();
  File "/home/****-crawler/releases/20210114184826/node_modules/@apify/storage-local/src/resource_clients/request_queue.js", line 74, col 29, in RequestQueueClient._getEmulator
    this.emulator = new RequestQueueEmulator({
  File "/home/****-crawler/releases/20210114184826/node_modules/@apify/storage-local/src/resource_clients/request_queue.js", line 84, col 18, in RequestQueueClient.get
    this._getEmulator().updateAccessedAtById(this.id);
  File "/home/****-crawler/releases/20210114184826/node_modules/apify/build/storages/storage_manager.js", line 97, col 53, in StorageManager._getOrCreateStorage
    const existingStorage = await storageClient.get();
  File "/home/****-crawler/releases/20210114184826/node_modules/apify/build/storages/storage_manager.js", line 52, col 46, in StorageManager.openStorage
    const storageObject = await this._getOrCreateStorage(idOrName, this.name, client);
  File "/home/****-crawler/releases/20210114184826/node_modules/apify/build/storages/request_queue.js", line 582, col 20, in Object.exports.openRequestQueue
    return manager.openStorage(queueIdOrName, options);
  File "/home/****-crawler/releases/20210114184826/spider/refresh.js", line 120, col 36, in crawl
    const requestQueue = await Apify.openRequestQueue(dealer.handle + '-refresh');
  File "/home/****-crawler/releases/20210114184826/spider/refresh.js", line 234, col 11, in null.<anonymous>
    await crawl();

To Reproduce It’s kind of impossible to reproduce right now as we didn’t change our code and the error only occurs occasionally and only after upgrading the SDK.

System information:

  • OS: 4.19.72-gentoo.mfu
  • Node.js version v12.18.1
  • Apify SDK version 0.22.4

Thanks, Chris

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 23 (11 by maintainers)

Most upvoted comments

I think it now is safe to say that it’s been fixed! Thanks @mnmkng 😃

1.0.0 will get the update automatically with fresh install, because it uses ^1.0.3 as the version for @apify/storage-local.

Hey @cspeer, sorry, finishing with something else at the moment, will probably have an update tomorrow. Will update here ASAP.