Skip to content

Commit 7c0724b

Browse files
authored
Merge branch 'master' into master
2 parents 7e6de9e + d78e19a commit 7c0724b

37 files changed

+815
-304
lines changed

.github/workflows/release.yml

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ on:
44
pull_request:
55
types: [closed]
66

7+
permissions:
8+
contents: write
9+
pull-requests: read
10+
711
jobs:
812
check-next-version:
913
runs-on: ubuntu-latest
@@ -105,6 +109,7 @@ jobs:
105109
run: |
106110
git config --global user.name "${{ github.actor }}"
107111
git config --global user.email "$(git log --format='%ae' HEAD^!)"
112+
git remote set-url origin https://${{ secrets.GIT_REPOSITORY_URL_USERNAME }}:${{ secrets.GIT_REPOSITORY_URL_ACCESS_TOKEN }}@github.com/capricorn86/happy-dom.git
108113
109114
- name: Creates release branch
110115
run: |

.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
legacy-peer-deps=true

docs/contributing.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ We are very happy that you would like to contribute. In this guide you will find
66

77
### Install
88

9-
We need to add "--legacy-peer-deps" to the install as a workaround to be able to install Vitest. Otherwise we get an "Cannot set properties of null (setting 'parent')" error as Vitest has "happy-dom" as peer dependency. Hopefully we can find a better solution in the future.
10-
119
```bash
12-
npm install --legacy-peer-deps
10+
npm install
1311
```
1412

1513
### Compile

package-lock.json

+205
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/happy-dom/src/async-task-manager/AsyncTaskManager.ts

+17-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const TIMER = {
1010
*/
1111
export default class AsyncTaskManager {
1212
private static taskID = 0;
13-
private runningTasks: { [k: string]: (destroy: boolean) => void } = {};
13+
private runningTasks: { [k: string]: (destroy: boolean) => void | Promise<void> } = {};
1414
private runningTaskCount = 0;
1515
private runningTimers: NodeJS.Timeout[] = [];
1616
private runningImmediates: NodeJS.Immediate[] = [];
@@ -189,8 +189,23 @@ export default class AsyncTaskManager {
189189
TIMER.clearTimeout(timer);
190190
}
191191

192+
const taskPromises = [];
193+
192194
for (const key of Object.keys(runningTasks)) {
193-
runningTasks[key](destroy);
195+
const returnValue = runningTasks[key](destroy);
196+
if (returnValue instanceof Promise) {
197+
taskPromises.push(returnValue);
198+
}
199+
}
200+
201+
if (taskPromises.length) {
202+
return Promise.all(taskPromises)
203+
.then(() => this.waitUntilComplete())
204+
.catch((error) => {
205+
/* eslint-disable-next-line no-console */
206+
console.error(error);
207+
throw error;
208+
});
194209
}
195210

196211
// We need to wait for microtasks to complete before resolving.

0 commit comments

Comments
 (0)