mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
Fixing time bug in webhook tests (#383)
Webhook tests were reusing date in logs, which caused a random failure in tests that checked updatedTime.
This commit is contained in:
@@ -655,7 +655,6 @@ export class DocTriggers {
|
||||
private async _sendWebhookWithRetries(id: string, url: string, body: string, size: number, signal: AbortSignal) {
|
||||
const maxWait = 64;
|
||||
let wait = 1;
|
||||
let now = Date.now();
|
||||
for (let attempt = 0; attempt < this._maxWebhookAttempts; attempt++) {
|
||||
if (this._shuttingDown) {
|
||||
return false;
|
||||
@@ -672,12 +671,11 @@ export class DocTriggers {
|
||||
},
|
||||
signal,
|
||||
});
|
||||
now = Date.now();
|
||||
if (response.status === 200) {
|
||||
await this._stats.logBatch(id, 'success', now, { size, httpStatus: 200, error: null, attempts: attempt + 1 });
|
||||
await this._stats.logBatch(id, 'success', { size, httpStatus: 200, error: null, attempts: attempt + 1 });
|
||||
return true;
|
||||
}
|
||||
await this._stats.logBatch(id, 'failure', now, {
|
||||
await this._stats.logBatch(id, 'failure', {
|
||||
httpStatus: response.status,
|
||||
error: await response.text(),
|
||||
attempts: attempt + 1,
|
||||
@@ -685,7 +683,7 @@ export class DocTriggers {
|
||||
});
|
||||
this._log(`Webhook responded with non-200 status`, {level: 'warn', status: response.status, attempt});
|
||||
} catch (e) {
|
||||
await this._stats.logBatch(id, 'failure', now, {
|
||||
await this._stats.logBatch(id, 'failure', {
|
||||
httpStatus: null,
|
||||
error: (e.message || 'Unrecognized error during fetch'),
|
||||
attempts: attempt + 1,
|
||||
@@ -873,7 +871,6 @@ class WebhookStatistics extends PersistedStore<StatsKey> {
|
||||
public async logBatch(
|
||||
id: string,
|
||||
status: WebhookBatchStatus,
|
||||
now?: number|null,
|
||||
stats?: {
|
||||
httpStatus?: number|null,
|
||||
error?: string|null,
|
||||
@@ -881,7 +878,7 @@ class WebhookStatistics extends PersistedStore<StatsKey> {
|
||||
attempts?: number|null,
|
||||
}
|
||||
) {
|
||||
now ??= Date.now();
|
||||
const now = Date.now();
|
||||
|
||||
// Update batchStats.
|
||||
const batchStats: [StatsKey, string][] = [
|
||||
|
||||
Reference in New Issue
Block a user