Skip to content

Commit

Permalink
chore: [capricorn86#1718] Adds fixes related to AbortSignal and Fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
capricorn86 committed Feb 21, 2025
1 parent 95cdd3e commit b98502e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
4 changes: 2 additions & 2 deletions packages/happy-dom/src/fetch/AbortSignal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export default class AbortSignal extends EventTarget {
: new this[PropertySymbol.window].DOMException(
'signal is aborted without reason',
DOMExceptionNameEnum.abortError
);
);
this[PropertySymbol.aborted] = true;
this.dispatchEvent(new Event('abort'));
}
Expand Down Expand Up @@ -118,7 +118,7 @@ export default class AbortSignal extends EventTarget {
: new this[PropertySymbol.window].DOMException(
'signal is aborted without reason',
DOMExceptionNameEnum.abortError
);
);
signal[PropertySymbol.aborted] = true;
return signal;
}
Expand Down
10 changes: 5 additions & 5 deletions packages/happy-dom/src/fetch/Fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export default class Fetch {
window: this.#window,
response: this.response,
request: this.request
})
})
: undefined;
return interceptedResponse instanceof Response ? interceptedResponse : this.response;
}
Expand Down Expand Up @@ -341,7 +341,7 @@ export default class Fetch {
window: this.#window,
response: await response,
request: this.request
})
})
: undefined;
this.#browserFrame[PropertySymbol.asyncTaskManager].endTask(taskID);
return interceptedResponse instanceof Response ? interceptedResponse : response;
Expand All @@ -364,7 +364,7 @@ export default class Fetch {
window: this.#window,
response: await response,
request: this.request
})
})
: undefined;
this.#browserFrame[PropertySymbol.asyncTaskManager].endTask(taskID);
return interceptedResponse instanceof Response ? interceptedResponse : response;
Expand All @@ -388,7 +388,7 @@ export default class Fetch {
window: this.#window,
response: await response,
request: this.request
})
})
: undefined;

this.#browserFrame[PropertySymbol.asyncTaskManager].endTask(taskID);
Expand Down Expand Up @@ -545,7 +545,7 @@ export default class Fetch {
window: this.#window,
response: await response,
request: this.request
})
})
: undefined;
this.#browserFrame[PropertySymbol.asyncTaskManager].endTask(taskID);
const returnResponse =
Expand Down
12 changes: 6 additions & 6 deletions packages/happy-dom/src/fetch/SyncFetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export default class SyncFetch {
? this.interceptor.beforeSyncRequest({
request: this.request,
window: this.#window
})
})
: undefined;

if (typeof beforeRequestResponse === 'object') {
Expand Down Expand Up @@ -139,7 +139,7 @@ export default class SyncFetch {
window: this.#window,
response,
request: this.request
})
})
: undefined;
return typeof interceptedResponse === 'object' ? interceptedResponse : response;
}
Expand Down Expand Up @@ -293,7 +293,7 @@ export default class SyncFetch {
window: this.#window,
response,
request: this.request
})
})
: undefined;
return typeof interceptedResponse === 'object' ? interceptedResponse : response;
}
Expand All @@ -312,7 +312,7 @@ export default class SyncFetch {
window: this.#window,
response,
request: this.request
})
})
: undefined;
return typeof interceptedResponse === 'object' ? interceptedResponse : response;
}
Expand All @@ -331,7 +331,7 @@ export default class SyncFetch {
window: this.#window,
response,
request: this.request
})
})
: undefined;
const returnResponse = typeof interceptedResponse === 'object' ? interceptedResponse : response;

Expand Down Expand Up @@ -528,7 +528,7 @@ export default class SyncFetch {
window: this.#window,
response: redirectedResponse,
request: this.request
})
})
: undefined;
const returnResponse =
typeof interceptedResponse === 'object' ? interceptedResponse : redirectedResponse;
Expand Down
1 change: 0 additions & 1 deletion packages/happy-dom/test/fetch/Fetch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { ReadableStream } from 'stream/web';
import { afterEach, describe, it, expect, vi } from 'vitest';
import FetchHTTPSCertificate from '../../src/fetch/certificate/FetchHTTPSCertificate.js';
import * as PropertySymbol from '../../src/PropertySymbol.js';
import { abort } from 'process';

const LAST_CHUNK = Buffer.from('0\r\n\r\n');

Expand Down

0 comments on commit b98502e

Please sign in to comment.