Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/job-manager/lib/JobManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const setTimeoutPromise = util.promisify(setTimeout);
const fastq = require('fastq');
const later = require('@breejs/later');
const Bree = require('bree');
const pWaitFor = require('p-wait-for');
const {UnhandledJobError, IncorrectUsageError} = require('@tryghost/errors');
const logging = require('@tryghost/logging');
const isCronExpression = require('./is-cron-expression');
Expand Down Expand Up @@ -407,7 +406,7 @@ class JobManager {
}

/**
* @param {import('p-wait-for').Options} [options]
* @param {object} [options]
*/
async shutdown(options) {
await this.bree.stop();
Expand All @@ -418,6 +417,7 @@ class JobManager {

logging.warn('Waiting for busy job in inline job queue');

const {default: pWaitFor} = await import('p-wait-for');
await pWaitFor(() => this.inlineQueue.idle() === true, options);

logging.warn('Inline job queue finished');
Expand Down
2 changes: 1 addition & 1 deletion packages/job-manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"bree": "9.2.9",
"cron-validate": "1.5.3",
"fastq": "1.20.1",
"p-wait-for": "3.2.0",
"p-wait-for": "6.0.0",
"workerpool": "10.0.1"
},
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/job-manager/test/examples/graceful-shutdown.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable no-console */

const pWaitFor = require('p-wait-for');
const path = require('path');
const setTimeoutPromise = require('util').promisify(setTimeout);
const JobManager = require('../../lib/job-manager');
Expand Down Expand Up @@ -29,6 +28,7 @@ async function shutdown(signal) {

await setTimeoutPromise(100); // allow job to get scheduled

const {default: pWaitFor} = await import('p-wait-for');
await pWaitFor(() => (Object.keys(jobManager.bree.workers).length === 0) && (Object.keys(jobManager.bree.intervals).length === 0));

process.exit(0);
Expand Down
2 changes: 1 addition & 1 deletion packages/job-manager/test/examples/scheduled-one-off.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const path = require('path');
const pWaitFor = require('p-wait-for');
const addSeconds = require('date-fns/addSeconds');
const JobManager = require('../../lib/job-manager');

Expand All @@ -23,6 +22,7 @@ const isJobQueueEmpty = (bree) => {
name: 'one-off-scheduled-job'
});

const {default: pWaitFor} = await import('p-wait-for');
await pWaitFor(() => (isJobQueueEmpty(jobManager.bree)));

process.exit(0);
Expand Down
3 changes: 1 addition & 2 deletions packages/webhook-mock-receiver/lib/WebhookMockReceiver.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const {AssertionError} = require('assert');
const {URL} = require('url');
const nock = require('nock');
const pWaitFor = require('p-wait-for');

class WebhookMockReceiver {
constructor({snapshotManager}) {
this.body;
Expand All @@ -19,6 +17,7 @@ class WebhookMockReceiver {

async receivedRequest() {
// @NOTE: figure out a better waiting mechanism here, don't allow it to hang forever
const {default: pWaitFor} = await import('p-wait-for');
await pWaitFor(() => this._receiver.isDone());
}

Expand Down
2 changes: 1 addition & 1 deletion packages/webhook-mock-receiver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
"sinon": "21.0.1"
},
"dependencies": {
"p-wait-for": "3.2.0"
"p-wait-for": "6.0.0"
}
}
7 changes: 6 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8111,13 +8111,18 @@ p-try@^2.0.0:
resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6"
integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==

p-wait-for@3, p-wait-for@3.2.0:
p-wait-for@3:
version "3.2.0"
resolved "https://registry.yarnpkg.com/p-wait-for/-/p-wait-for-3.2.0.tgz#640429bcabf3b0dd9f492c31539c5718cb6a3f1f"
integrity sha512-wpgERjNkLrBiFmkMEjuZJEWKKDrNfHCKA1OhyN1wg1FrLkULbviEy6py1AyJUgZ72YWFbZ38FIpnqvVqAlDUwA==
dependencies:
p-timeout "^3.0.0"

p-wait-for@6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/p-wait-for/-/p-wait-for-6.0.0.tgz#c31fdf0a40e2154968a26abc835688d1226dcaa3"
integrity sha512-2kKzMtjS8TVcpCOU/gr3vZ4K/WIyS1AsEFXFWapM/0lERCdyTbB6ZeuCIp+cL1aeLZfQoMdZFCBTHiK4I9UtOw==

package-json-from-dist@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz#4f1471a010827a86f94cfd9b0727e36d267de505"
Expand Down