Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function deprecateRecordIfExpired(mergedConfig) {
if (mergedConfig.hasOwnProperty('recordIfExpired')) {
console.warn(
'[Polly] config option "recordIfExpired" is deprecated. Please use "expiryStrategy".'
);
if (mergedConfig.recordIfExpired) {
// replace recordIfExpired: true with expiryStrategy: record
mergedConfig.expiryStrategy = EXPIRY_STRATEGIES.RECORD;
} else {
// replace recordIfExpired: false with expiryStrategy: warn
mergedConfig.expiryStrategy = EXPIRY_STRATEGIES.WARN;
}
delete mergedConfig.recordIfExpired;
}
return mergedConfig;
}
if (isExpired(recordingEntry.startedDateTime, config.expiresIn)) {
const message =
'Recording for the following request has expired.\n' +
`${stringifyRequest(pollyRequest, null, 2)}`;
switch (config.expiryStrategy) {
// exit into the record flow if expiryStrategy is "record".
case EXPIRY_STRATEGIES.RECORD:
return this.record(pollyRequest);
// throw an error and exit if expiryStrategy is "error".
case EXPIRY_STRATEGIES.ERROR:
this.assert(message);
break;
// log a warning and continue if expiryStrategy is "warn".
case EXPIRY_STRATEGIES.WARN:
console.warn(`[Polly] ${message}`);
break;
// throw an error if we encounter an unsupported expiryStrategy.
default:
this.assert(
`Invalid config option passed for "expiryStrategy": "${config.expiryStrategy}"`
);
break;
}
}
await this.timeout(pollyRequest, recordingEntry);
pollyRequest.action = ACTIONS.REPLAY;
return this.onReplay(
pollyRequest,
adapters: [],
adapterOptions: {},
persister: null,
persisterOptions: {
keepUnusedRequests: false
},
logging: false,
recordIfMissing: true,
recordFailedRequests: false,
expiresIn: null,
expiryStrategy: EXPIRY_STRATEGIES.WARN,
timing: Timing.fixed(0),
matchRequestsBy: {
method: true,
headers: true,
body: true,
order: true,
url: {
protocol: true,
username: true,
password: true,
hostname: true,
port: true,
pathname: true,
query: true,