From 52a8e4f770dd79bd06aedeb91fb84945e86790b8 Mon Sep 17 00:00:00 2001 From: Matt Gaunt Date: Mon, 12 Feb 2018 17:11:31 -0800 Subject: [PATCH] Adding assertiong for addRequest --- packages/workbox-background-sync/Queue.mjs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/workbox-background-sync/Queue.mjs b/packages/workbox-background-sync/Queue.mjs index 200ebd0cf..b1749250e 100644 --- a/packages/workbox-background-sync/Queue.mjs +++ b/packages/workbox-background-sync/Queue.mjs @@ -15,6 +15,7 @@ import {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs'; import {logger} from 'workbox-core/_private/logger.mjs'; +import {assert} from 'workbox-core/_private/assert.mjs'; import {QueueStore} from './models/QueueStore.mjs'; import StorableRequest from './models/StorableRequest.mjs'; import {TAG_PREFIX, MAX_RETENTION_TIME} from './utils/constants.mjs'; @@ -90,6 +91,15 @@ class Queue { * @param {Request} request The request object to store. */ async addRequest(request) { + if (process.env.NODE_ENV !== 'production') { + assert.isInstance(request, Request, { + moduleName: 'workbox-background-sync', + className: 'Queue', + funcName: 'addRequest', + paramName: 'request', + }); + } + const storableRequest = await StorableRequest.fromRequest(request.clone()); await this._runCallback('requestWillEnqueue', storableRequest); await this._queueStore.addEntry(storableRequest);