From c16a9b4df8d0fed2512cdee329afdff73d0ff891 Mon Sep 17 00:00:00 2001 From: gords2 <222919019+gords2@users.noreply.github.com> Date: Fri, 4 Sep 2026 08:14:39 -0700 Subject: [PATCH 01/10] fix(api): correct ReadableStreamDefaultController.desiredSize value type (#44536) * ReadableStreamDefaultController.desiredSize: correct value type desiredSize is not always an integer: with a custom queuing strategy the chunk sizes (and therefore desiredSize) can be non-integer. It is also null when the stream has errored and 0 when it is closed. * Fix others --------- Co-authored-by: Joshua Chen --- .../api/readablebytestreamcontroller/desiredsize/index.md | 4 ++-- .../readablestreamdefaultcontroller/desiredsize/index.md | 4 +++- .../transformstreamdefaultcontroller/desiredsize/index.md | 4 +++- .../api/writablestreamdefaultwriter/desiredsize/index.md | 6 ++---- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/files/en-us/web/api/readablebytestreamcontroller/desiredsize/index.md b/files/en-us/web/api/readablebytestreamcontroller/desiredsize/index.md index 5cd4f82cc8ac165..1f09392436f90c5 100644 --- a/files/en-us/web/api/readablebytestreamcontroller/desiredsize/index.md +++ b/files/en-us/web/api/readablebytestreamcontroller/desiredsize/index.md @@ -17,9 +17,9 @@ The `desiredSize` is used to apply [backpressure](/en-US/docs/Web/API/Streams_AP ## Value -An integer. Note that this can be negative if the queue is over-full. +A number, or `null`. -The value will be `null` if the stream has errored and `0` if it is closed. +The number can be negative if the queue is over-full. Although the queue size is measured in bytes, a fractional [high water mark](/en-US/docs/Web/API/Streams_API/Concepts#internal_queues_and_queuing_strategies) can cause the number to have a fractional component. The value is `null` if the stream has errored and `0` if it is closed. ## Examples diff --git a/files/en-us/web/api/readablestreamdefaultcontroller/desiredsize/index.md b/files/en-us/web/api/readablestreamdefaultcontroller/desiredsize/index.md index 7762ab39655f806..93cd59d4ec73ed6 100644 --- a/files/en-us/web/api/readablestreamdefaultcontroller/desiredsize/index.md +++ b/files/en-us/web/api/readablestreamdefaultcontroller/desiredsize/index.md @@ -14,7 +14,9 @@ required to fill the stream's internal queue. ## Value -An integer. Note that this can be negative if the queue is over-full. +A number, or `null`. + +The number can be negative if the queue is over-full. When a custom queuing strategy is used, its chunk sizes can cause the number to have a fractional component. The value is `null` if the stream has errored and `0` if it is closed. ## Examples diff --git a/files/en-us/web/api/transformstreamdefaultcontroller/desiredsize/index.md b/files/en-us/web/api/transformstreamdefaultcontroller/desiredsize/index.md index bb8a5b8e9025bcb..b7684b529f0ebad 100644 --- a/files/en-us/web/api/transformstreamdefaultcontroller/desiredsize/index.md +++ b/files/en-us/web/api/transformstreamdefaultcontroller/desiredsize/index.md @@ -16,7 +16,9 @@ If the `desiredSize` is `0` then the queue is full. Therefore you can use this i ## Value -The desired size. +A number, or `null`. + +The number can be negative if the queue is over-full. When a custom readable queuing strategy is used, its chunk sizes can cause the number to have a fractional component. The value is `null` if the readable side has errored and `0` if it is closed. ## Examples diff --git a/files/en-us/web/api/writablestreamdefaultwriter/desiredsize/index.md b/files/en-us/web/api/writablestreamdefaultwriter/desiredsize/index.md index e7bcf75f268d533..cc17aa66a3cc2e5 100644 --- a/files/en-us/web/api/writablestreamdefaultwriter/desiredsize/index.md +++ b/files/en-us/web/api/writablestreamdefaultwriter/desiredsize/index.md @@ -14,11 +14,9 @@ to fill the stream's internal queue. ## Value -An integer. Note that this can be negative if the queue is over-full. +A number, or `null`. -The value will be `null` if the stream cannot be successfully written to -(due to either being errored, or having an abort queued up), and zero if the stream is -closed. +The number can be negative if the queue is over-full. When a custom queuing strategy is used, its chunk sizes can cause the number to have a fractional component. The value is `null` if the stream is erroring or errored, and `0` if it is closed. ### Exceptions From d28dc75f4d1d9430e250b51b7b0dc78498e0eeed Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 4 Sep 2026 17:25:51 +0200 Subject: [PATCH 02/10] build(deps-dev): bump cspell from 10.2.1 to 10.2.2 (#45503) Bumps [cspell](https://github.com/streetsidesoftware/cspell/tree/HEAD/packages/cspell) from 10.2.1 to 10.2.2. - [Release notes](https://github.com/streetsidesoftware/cspell/releases) - [Changelog](https://github.com/streetsidesoftware/cspell/blob/main/packages/cspell/CHANGELOG.md) - [Commits](https://github.com/streetsidesoftware/cspell/commits/v10.2.2/packages/cspell) --- updated-dependencies: - dependency-name: cspell dependency-version: 10.2.2 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package-lock.json | 232 +++++++++++++++++++++++----------------------- package.json | 2 +- 2 files changed, 117 insertions(+), 117 deletions(-) diff --git a/package-lock.json b/package-lock.json index 23bbc8da2d8eadc..f6c46e36f29e1b9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,7 @@ "cheerio": "1.2.0", "cli-progress": "^3.12.0", "cross-env": "10.1.0", - "cspell": "10.2.1", + "cspell": "10.2.2", "cspell-group-by-file-reporter": "^1.0.1", "env-cmd": "11.0.0", "fdir": "^6.5.0", @@ -262,9 +262,9 @@ } }, "node_modules/@cspell/cspell-bundled-dicts": { - "version": "10.2.1", - "resolved": "https://registry.npmjs.org/@cspell/cspell-bundled-dicts/-/cspell-bundled-dicts-10.2.1.tgz", - "integrity": "sha512-SG2JTrfPrQUApSvYmfuj6dtIY5i+UHgzPsZPVHu+xbuKxca9E3ic4W74YnwmVNl0Qrs5nxUiBGlkwRd58sL6uw==", + "version": "10.2.2", + "resolved": "https://registry.npmjs.org/@cspell/cspell-bundled-dicts/-/cspell-bundled-dicts-10.2.2.tgz", + "integrity": "sha512-327sQUcfHjr9TnkX2FYluLuQHSoWjSm9AiPFBpULxHofk7VvKfye12Ur4xMbOzyv7cxMROx/OeYF0oytLuLsvQ==", "dev": true, "license": "MIT", "dependencies": { @@ -333,22 +333,22 @@ } }, "node_modules/@cspell/cspell-json-reporter": { - "version": "10.2.1", - "resolved": "https://registry.npmjs.org/@cspell/cspell-json-reporter/-/cspell-json-reporter-10.2.1.tgz", - "integrity": "sha512-X/sut5Prad3pwSURckszEjfNiObmlia9jC4pTbQl1o1dOBstQ0cqYf23Zr5YtOGqCVoL34XdI+MsUQSSL4szAw==", + "version": "10.2.2", + "resolved": "https://registry.npmjs.org/@cspell/cspell-json-reporter/-/cspell-json-reporter-10.2.2.tgz", + "integrity": "sha512-gm9J5COxrLqb4WV2EX6x2INoRDOq3shiaFNhUu3cOhb8YHj5e/IPJ+uVT9nBl9BZKGVRX82vseezkiss9ofiGw==", "dev": true, "license": "MIT", "dependencies": { - "@cspell/cspell-types": "10.2.1" + "@cspell/cspell-types": "10.2.2" }, "engines": { "node": ">=22.18.0" } }, "node_modules/@cspell/cspell-performance-monitor": { - "version": "10.2.1", - "resolved": "https://registry.npmjs.org/@cspell/cspell-performance-monitor/-/cspell-performance-monitor-10.2.1.tgz", - "integrity": "sha512-0/vDTp8EatMGHnZg/Ha5/LuvgH9qglOOTLgnN5T8WIGIN7c2yrP0kIMzRiGqweaTPm8zfX1uZAYV7Uz4Yy/DIg==", + "version": "10.2.2", + "resolved": "https://registry.npmjs.org/@cspell/cspell-performance-monitor/-/cspell-performance-monitor-10.2.2.tgz", + "integrity": "sha512-BPPKqUPvRH7KEx5cnZY2KJHA81+V002pJirUkxT3gsrqLP/a3C0CWsZ/ST9f8ZE8OLNLHnmNkPizRPiDHada4Q==", "dev": true, "license": "MIT", "engines": { @@ -356,9 +356,9 @@ } }, "node_modules/@cspell/cspell-pipe": { - "version": "10.2.1", - "resolved": "https://registry.npmjs.org/@cspell/cspell-pipe/-/cspell-pipe-10.2.1.tgz", - "integrity": "sha512-IKuqlCzWfqIfYGLnhTw29neBPCg3Q6rkRInspfbLmonYXrPYC0sWKJnvIchV05JaXhiT1kvUey19MsE1U1bQiQ==", + "version": "10.2.2", + "resolved": "https://registry.npmjs.org/@cspell/cspell-pipe/-/cspell-pipe-10.2.2.tgz", + "integrity": "sha512-WP+kwmg9ltgjXo5N8m0Xwchgob6wJ+c5omY4/WNSLsyEncuRjK1e6wYYN/gs+D/d3ISzC8+yb5Ma13ymkEC+4Q==", "dev": true, "license": "MIT", "engines": { @@ -366,9 +366,9 @@ } }, "node_modules/@cspell/cspell-resolver": { - "version": "10.2.1", - "resolved": "https://registry.npmjs.org/@cspell/cspell-resolver/-/cspell-resolver-10.2.1.tgz", - "integrity": "sha512-AKRof1VT5u3FxEK/np+0dFNZt3DGyQhu/AL7Nwvph5HpP6JZhRiqdcTION0iv0fal3RI0tKo93pQekhAiIaPzQ==", + "version": "10.2.2", + "resolved": "https://registry.npmjs.org/@cspell/cspell-resolver/-/cspell-resolver-10.2.2.tgz", + "integrity": "sha512-DZO2vALwXVi8ajkS0p0DHPD4Uzq86fHBLksZF3MJOWV2nBZxrrUI1/kXA3Fiuil/EXSJG3tf0WX5/efoamP2Iw==", "dev": true, "license": "MIT", "dependencies": { @@ -379,9 +379,9 @@ } }, "node_modules/@cspell/cspell-service-bus": { - "version": "10.2.1", - "resolved": "https://registry.npmjs.org/@cspell/cspell-service-bus/-/cspell-service-bus-10.2.1.tgz", - "integrity": "sha512-foUAEQ/VsH/JXCddjAo84KZwkwBDP23hJ2/rjFxcoj2zEKYzkgjbwt2Pfsgv+pmMwtDu+zKyLLV4uuY2JnngiA==", + "version": "10.2.2", + "resolved": "https://registry.npmjs.org/@cspell/cspell-service-bus/-/cspell-service-bus-10.2.2.tgz", + "integrity": "sha512-0UEvuTZ/mLQXg5iy1w7xzUf0gACGnaFRuY7yac7aFQjM//rP+2BXK8bC6g+4reqwBJhjeDrEHy7SvvDICgGMAg==", "dev": true, "license": "MIT", "engines": { @@ -389,9 +389,9 @@ } }, "node_modules/@cspell/cspell-types": { - "version": "10.2.1", - "resolved": "https://registry.npmjs.org/@cspell/cspell-types/-/cspell-types-10.2.1.tgz", - "integrity": "sha512-R9agOEKdMy1rl12YdOkp+WQK27+SW/RvmtHOf1qASbDfFsVTq9oAbxTTiVXKu3MW67dqFr8gGLRaSQYjVKG2fA==", + "version": "10.2.2", + "resolved": "https://registry.npmjs.org/@cspell/cspell-types/-/cspell-types-10.2.2.tgz", + "integrity": "sha512-QfB4ux76pdgOmlhB2IUZKmkq/Ce4nojIlXzGlWGPj+gSuGC6bakL6f5lt4I0YAM8hxOwYPFvJRfkqebym1VtyQ==", "dev": true, "license": "MIT", "engines": { @@ -399,13 +399,13 @@ } }, "node_modules/@cspell/cspell-worker": { - "version": "10.2.1", - "resolved": "https://registry.npmjs.org/@cspell/cspell-worker/-/cspell-worker-10.2.1.tgz", - "integrity": "sha512-64XywkoHgj6pHtpWemoTHw1NG7ZRIc5P7m0zQrAJ6bIYTh3AypTnOWSjEaFw3F6v6GovuRMLFdUXAPIxoamr/g==", + "version": "10.2.2", + "resolved": "https://registry.npmjs.org/@cspell/cspell-worker/-/cspell-worker-10.2.2.tgz", + "integrity": "sha512-IIoICOihmGbEftfBN35hpD5q0eS8yjzVst7Fvpbjo+XfyuUwZQNg9jzPOW4nNUskzpJT3puDRbZ8AxrodS5Kpw==", "dev": true, "license": "MIT", "dependencies": { - "cspell-lib": "10.2.1" + "cspell-lib": "10.2.2" }, "engines": { "node": ">=22.18.0" @@ -837,13 +837,13 @@ "license": "MIT" }, "node_modules/@cspell/dynamic-import": { - "version": "10.2.1", - "resolved": "https://registry.npmjs.org/@cspell/dynamic-import/-/dynamic-import-10.2.1.tgz", - "integrity": "sha512-9+CLdw6blUYV2RWx5F+DumYiFmb19uUTlYPwd/iIw6hf+KsxblPfpCjUAn8Jt9CVhg1gPY8rRR2QPLpEAGbG0g==", + "version": "10.2.2", + "resolved": "https://registry.npmjs.org/@cspell/dynamic-import/-/dynamic-import-10.2.2.tgz", + "integrity": "sha512-nYu5CP0OERXGoA1neXI7ieBSI9RSq79vTpWY4sZyK3Z9y8sL077jR3sQI5Q1ePb5tKFXof1UmRdgLS3F0Ef3uA==", "dev": true, "license": "MIT", "dependencies": { - "@cspell/url": "10.2.1", + "@cspell/url": "10.2.2", "import-meta-resolve": "^4.2.0" }, "engines": { @@ -851,9 +851,9 @@ } }, "node_modules/@cspell/filetypes": { - "version": "10.2.1", - "resolved": "https://registry.npmjs.org/@cspell/filetypes/-/filetypes-10.2.1.tgz", - "integrity": "sha512-uXmrQs+S2G38q5crUA29RVHK37nnoxAXG10eU8u5yTtVKdQ+4TF7sUY0gr8RbKp6bZVCFkQ10Z/GC/ikupoYgQ==", + "version": "10.2.2", + "resolved": "https://registry.npmjs.org/@cspell/filetypes/-/filetypes-10.2.2.tgz", + "integrity": "sha512-UWuvbNb2rLUwClzX8V5dY2hmURlCzpyXlnUUQL3NM3eJrghSDaDmb7uqfCIiObg2F3+E/6z1dgx2QkcA0luYQQ==", "dev": true, "license": "MIT", "engines": { @@ -861,9 +861,9 @@ } }, "node_modules/@cspell/rpc": { - "version": "10.2.1", - "resolved": "https://registry.npmjs.org/@cspell/rpc/-/rpc-10.2.1.tgz", - "integrity": "sha512-BbxmkiHkbYB5jsARTImrkQvDUMq/pSxhvwFySVL4KxvFqGgisTJt9fnP3VoAPpxkGhIpLX/V70oGNlZfE/Ydww==", + "version": "10.2.2", + "resolved": "https://registry.npmjs.org/@cspell/rpc/-/rpc-10.2.2.tgz", + "integrity": "sha512-pF4Ekt6eZZKCmdr3IqTtjfoc5UVMXI89HhCYCc4l+GRLjTDPjCX5ekuvy2asByI30NBJUETsNc6yVtmSKZ/9UQ==", "dev": true, "license": "MIT", "engines": { @@ -871,9 +871,9 @@ } }, "node_modules/@cspell/strong-weak-map": { - "version": "10.2.1", - "resolved": "https://registry.npmjs.org/@cspell/strong-weak-map/-/strong-weak-map-10.2.1.tgz", - "integrity": "sha512-P05H3wLn9B41DZ1v4dmNurvLdV0X1lCezqV7xqjSQ4J3fUCshk9paBboK6XSScvC4oXhmeOHrLpaORrKvxPgwg==", + "version": "10.2.2", + "resolved": "https://registry.npmjs.org/@cspell/strong-weak-map/-/strong-weak-map-10.2.2.tgz", + "integrity": "sha512-eXhJbPoPBzERBHncrZ02uNAS+cfvLKWGWbdaZ/R+sHZbbU3Sc4gnclQz+RRd2Vw3Q8Fra+o9ZLxAKFMB/ljvJw==", "dev": true, "license": "MIT", "engines": { @@ -881,9 +881,9 @@ } }, "node_modules/@cspell/url": { - "version": "10.2.1", - "resolved": "https://registry.npmjs.org/@cspell/url/-/url-10.2.1.tgz", - "integrity": "sha512-QRds4VhWjSL3iKaXYlXoasQt2eSN622xIJlfwyD4aeB8x8zmzJEP29C8YQFt1Jsde6/smNMvYWhIETFcdDSkJA==", + "version": "10.2.2", + "resolved": "https://registry.npmjs.org/@cspell/url/-/url-10.2.2.tgz", + "integrity": "sha512-KC+Rzi9mExB1rzxoT3ysC98tGhiSbgkOXc6U8fbJmoggFswfwwJEzwa2NUNX75Thlty5ZzaPandLS4P0dh4kOA==", "dev": true, "license": "MIT", "engines": { @@ -2838,29 +2838,29 @@ } }, "node_modules/cspell": { - "version": "10.2.1", - "resolved": "https://registry.npmjs.org/cspell/-/cspell-10.2.1.tgz", - "integrity": "sha512-GbuGONUmSGfPtwUw1D63p5tEElAZ7PWp8EFDteyubxJHzS8VgHCmZ37fNP2uRrkqEvE3goYFIAGFhGwphQVfbw==", + "version": "10.2.2", + "resolved": "https://registry.npmjs.org/cspell/-/cspell-10.2.2.tgz", + "integrity": "sha512-lQF469/Y3Fz5nlnQoAuA1ZDDheyCMNDyS3LBbAeoKL1gUKTDypH0qA6mqbp3KoZNicqGIxZoW3RoYkZ7v1tpZQ==", "dev": true, "license": "MIT", "dependencies": { - "@cspell/cspell-json-reporter": "10.2.1", - "@cspell/cspell-performance-monitor": "10.2.1", - "@cspell/cspell-pipe": "10.2.1", - "@cspell/cspell-types": "10.2.1", - "@cspell/cspell-worker": "10.2.1", - "@cspell/dynamic-import": "10.2.1", - "@cspell/url": "10.2.1", + "@cspell/cspell-json-reporter": "10.2.2", + "@cspell/cspell-performance-monitor": "10.2.2", + "@cspell/cspell-pipe": "10.2.2", + "@cspell/cspell-types": "10.2.2", + "@cspell/cspell-worker": "10.2.2", + "@cspell/dynamic-import": "10.2.2", + "@cspell/url": "10.2.2", "ansi-regex": "^6.3.0", "chalk": "^6.0.0", "chalk-template": "^1.1.2", "commander": "^15.0.0", - "cspell-config-lib": "10.2.1", - "cspell-dictionary": "10.2.1", - "cspell-gitignore": "10.2.1", - "cspell-glob": "10.2.1", - "cspell-io": "10.2.1", - "cspell-lib": "10.2.1", + "cspell-config-lib": "10.2.2", + "cspell-dictionary": "10.2.2", + "cspell-gitignore": "10.2.2", + "cspell-glob": "10.2.2", + "cspell-io": "10.2.2", + "cspell-lib": "10.2.2", "fast-json-stable-stringify": "^2.1.0", "flatted": "^3.4.4", "semver": "^7.8.5", @@ -2878,13 +2878,13 @@ } }, "node_modules/cspell-config-lib": { - "version": "10.2.1", - "resolved": "https://registry.npmjs.org/cspell-config-lib/-/cspell-config-lib-10.2.1.tgz", - "integrity": "sha512-KVykJLj+MewODWDT0CqyBKQZU9jlPoT293ody4Nj5P3t5SCxYxVCpCosDNrwMcJj+ePWaufPX7KnRWVBg63l1Q==", + "version": "10.2.2", + "resolved": "https://registry.npmjs.org/cspell-config-lib/-/cspell-config-lib-10.2.2.tgz", + "integrity": "sha512-pVWQOXb6gYLx+JTNxhqWaI4qTtNXnMYtPWauQsjoHsjzQsrIeM8whhXpX5G/dt+7IriUrQNNoH1x+cCkbMQ4UA==", "dev": true, "license": "MIT", "dependencies": { - "@cspell/cspell-types": "10.2.1", + "@cspell/cspell-types": "10.2.2", "comment-json": "^5.0.0", "smol-toml": "^1.8.0", "yaml": "^2.9.0" @@ -2907,16 +2907,16 @@ } }, "node_modules/cspell-dictionary": { - "version": "10.2.1", - "resolved": "https://registry.npmjs.org/cspell-dictionary/-/cspell-dictionary-10.2.1.tgz", - "integrity": "sha512-yc6KUP6SvZq8fEAmmQvIKkX127skqxUcTfx3eTc9frr6hkzX3bLgGv1nJWiG0QXkXyFyZKJI95NvlDHT7urBDA==", + "version": "10.2.2", + "resolved": "https://registry.npmjs.org/cspell-dictionary/-/cspell-dictionary-10.2.2.tgz", + "integrity": "sha512-UbdKjoiFabeJMax/CPxWU5/ut7AvQ7h/s0OgHRjDdX9do1uKdURvLhe6UlesP2w01krioAGi//ZkV1JCZOOOSg==", "dev": true, "license": "MIT", "dependencies": { - "@cspell/cspell-performance-monitor": "10.2.1", - "@cspell/cspell-pipe": "10.2.1", - "@cspell/cspell-types": "10.2.1", - "cspell-trie-lib": "10.2.1", + "@cspell/cspell-performance-monitor": "10.2.2", + "@cspell/cspell-pipe": "10.2.2", + "@cspell/cspell-types": "10.2.2", + "cspell-trie-lib": "10.2.2", "fast-equals": "^6.0.2" }, "engines": { @@ -2934,15 +2934,15 @@ } }, "node_modules/cspell-gitignore": { - "version": "10.2.1", - "resolved": "https://registry.npmjs.org/cspell-gitignore/-/cspell-gitignore-10.2.1.tgz", - "integrity": "sha512-7MH+/O8E3nQ1pf1WCruiwR5D+3m5ipCl7mWehd/rzUdCLbYlVfybsLtyVeb2TruRhaizVEHsXV5kMip7qCCa7w==", + "version": "10.2.2", + "resolved": "https://registry.npmjs.org/cspell-gitignore/-/cspell-gitignore-10.2.2.tgz", + "integrity": "sha512-/l0nF5jBqnowXcIMbLDCjFE8sKM6lKs4NjMa87JjYiOCx/LqN3rusL/Dkumws/NB2o5NUxqDRtitiYxw7tWlvQ==", "dev": true, "license": "MIT", "dependencies": { - "@cspell/url": "10.2.1", - "cspell-glob": "10.2.1", - "cspell-io": "10.2.1" + "@cspell/url": "10.2.2", + "cspell-glob": "10.2.2", + "cspell-io": "10.2.2" }, "bin": { "cspell-gitignore": "bin.mjs" @@ -2952,13 +2952,13 @@ } }, "node_modules/cspell-glob": { - "version": "10.2.1", - "resolved": "https://registry.npmjs.org/cspell-glob/-/cspell-glob-10.2.1.tgz", - "integrity": "sha512-VaEpSORqOpqJMISaMpCEf8ERGwUNYIYEvSJlJ4/7pVHELwt50aCWCncmvg1RLc53eRff5FtP8xSL04x/a4fg5Q==", + "version": "10.2.2", + "resolved": "https://registry.npmjs.org/cspell-glob/-/cspell-glob-10.2.2.tgz", + "integrity": "sha512-T1icxtdrv9QXETC0IQMBWPTNDxBYw4MPc0Z2iDPGFUjwWyYw2SBH8vC+S2HoXHt47BXg8Y2t6zbkPPkXlK1OzQ==", "dev": true, "license": "MIT", "dependencies": { - "@cspell/url": "10.2.1", + "@cspell/url": "10.2.2", "picomatch": "^4.0.7" }, "engines": { @@ -2966,14 +2966,14 @@ } }, "node_modules/cspell-grammar": { - "version": "10.2.1", - "resolved": "https://registry.npmjs.org/cspell-grammar/-/cspell-grammar-10.2.1.tgz", - "integrity": "sha512-l5FG12w0WuxKDkYYSvvl0yc7INyFTyqubQFHmEcihNjammGHb4pi1Pu+U1ADu/r+XAIHw9D6eWVaVwJnsux23A==", + "version": "10.2.2", + "resolved": "https://registry.npmjs.org/cspell-grammar/-/cspell-grammar-10.2.2.tgz", + "integrity": "sha512-GYLzoFT14FTuTmkwgzQzXInC1aUB/Wb7GzTrA7Gj8mrXFfHC/zJ1oTXufAY1fS9oGvYezvjb2LWPoMM+schmnA==", "dev": true, "license": "MIT", "dependencies": { - "@cspell/cspell-pipe": "10.2.1", - "@cspell/cspell-types": "10.2.1" + "@cspell/cspell-pipe": "10.2.2", + "@cspell/cspell-types": "10.2.2" }, "bin": { "cspell-grammar": "bin.mjs" @@ -2993,42 +2993,42 @@ } }, "node_modules/cspell-io": { - "version": "10.2.1", - "resolved": "https://registry.npmjs.org/cspell-io/-/cspell-io-10.2.1.tgz", - "integrity": "sha512-7aWbYnwsEMjWxUfYDqXYUE+cxHhy58njRlm2gtHQXYRrwy5GxyTDM8S8kRFFuiP/p7SKSQ3EctgVKRkVXRIE4Q==", + "version": "10.2.2", + "resolved": "https://registry.npmjs.org/cspell-io/-/cspell-io-10.2.2.tgz", + "integrity": "sha512-ksMJwWNk2es4c9zv1yL85whDmwVM8gddRxLSRBCIqTxOUelpfE7498Ci8XvfUauWgbdHqlaTuEmCqSMzK3xIQw==", "dev": true, "license": "MIT", "dependencies": { - "@cspell/cspell-service-bus": "10.2.1", - "@cspell/url": "10.2.1" + "@cspell/cspell-service-bus": "10.2.2", + "@cspell/url": "10.2.2" }, "engines": { "node": ">=22.18.0" } }, "node_modules/cspell-lib": { - "version": "10.2.1", - "resolved": "https://registry.npmjs.org/cspell-lib/-/cspell-lib-10.2.1.tgz", - "integrity": "sha512-CLU0Jh5qLQVofZOM8peexMzUE27FqXZqnXU9nvSGzH8v/BxgPLVgoBeJKdgJgUnArg2MmO30HBobXcekuvk/5A==", - "dev": true, - "license": "MIT", - "dependencies": { - "@cspell/cspell-bundled-dicts": "10.2.1", - "@cspell/cspell-performance-monitor": "10.2.1", - "@cspell/cspell-pipe": "10.2.1", - "@cspell/cspell-resolver": "10.2.1", - "@cspell/cspell-types": "10.2.1", - "@cspell/dynamic-import": "10.2.1", - "@cspell/filetypes": "10.2.1", - "@cspell/rpc": "10.2.1", - "@cspell/strong-weak-map": "10.2.1", - "@cspell/url": "10.2.1", - "cspell-config-lib": "10.2.1", - "cspell-dictionary": "10.2.1", - "cspell-glob": "10.2.1", - "cspell-grammar": "10.2.1", - "cspell-io": "10.2.1", - "cspell-trie-lib": "10.2.1", + "version": "10.2.2", + "resolved": "https://registry.npmjs.org/cspell-lib/-/cspell-lib-10.2.2.tgz", + "integrity": "sha512-d9ElvCs34f5aoVEOr0aP2iqUQYjrgvETept3HIbp67cwxKLkhygO1F8Ce6vcQ+G9PiGM6DrCuwHq8zvqGbJ0LQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@cspell/cspell-bundled-dicts": "10.2.2", + "@cspell/cspell-performance-monitor": "10.2.2", + "@cspell/cspell-pipe": "10.2.2", + "@cspell/cspell-resolver": "10.2.2", + "@cspell/cspell-types": "10.2.2", + "@cspell/dynamic-import": "10.2.2", + "@cspell/filetypes": "10.2.2", + "@cspell/rpc": "10.2.2", + "@cspell/strong-weak-map": "10.2.2", + "@cspell/url": "10.2.2", + "cspell-config-lib": "10.2.2", + "cspell-dictionary": "10.2.2", + "cspell-glob": "10.2.2", + "cspell-grammar": "10.2.2", + "cspell-io": "10.2.2", + "cspell-trie-lib": "10.2.2", "env-paths": "^4.0.0", "gensequence": "^8.0.8", "import-fresh": "^4.0.0", @@ -3042,16 +3042,16 @@ } }, "node_modules/cspell-trie-lib": { - "version": "10.2.1", - "resolved": "https://registry.npmjs.org/cspell-trie-lib/-/cspell-trie-lib-10.2.1.tgz", - "integrity": "sha512-nNvx9qVKfHzqV3Yy0TIv5haRS2IRNRimocOa/7K0yoB4OHS984HOtgYJPtArUs8G3LZvYuakcN35R7DpxcLXVA==", + "version": "10.2.2", + "resolved": "https://registry.npmjs.org/cspell-trie-lib/-/cspell-trie-lib-10.2.2.tgz", + "integrity": "sha512-n+dscSwWLSWcN/tQhv2wJziX/AfPxRVffr6YkGOcVCov1YaL3XoWpR0f6Yk16281s231hUcLEPgcWzISTs09dw==", "dev": true, "license": "MIT", "engines": { "node": ">=22.18.0" }, "peerDependencies": { - "@cspell/cspell-types": "10.2.1" + "@cspell/cspell-types": "10.2.2" } }, "node_modules/cspell/node_modules/chalk": { diff --git a/package.json b/package.json index e44fed6ada7e8b8..86a4c451851e182 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "cheerio": "1.2.0", "cli-progress": "^3.12.0", "cross-env": "10.1.0", - "cspell": "10.2.1", + "cspell": "10.2.2", "cspell-group-by-file-reporter": "^1.0.1", "env-cmd": "11.0.0", "fdir": "^6.5.0", From 5c8d0ac21db572edebbd4ad428efca0af3ec1734 Mon Sep 17 00:00:00 2001 From: Joshua Chen Date: Fri, 4 Sep 2026 10:06:38 -0700 Subject: [PATCH 03/10] More formally define expressions and operators (#45469) * More formally define expressions and operators * Grammar fix * Reviews * Apply batched suggestions from code review Co-authored-by: Joshua Chen --- .../functions/arrow_functions/index.md | 2 +- .../reference/lexical_grammar/index.md | 2 +- .../javascript/reference/operators/index.md | 20 +++++++++++++++- .../operators/operator_precedence/index.md | 2 +- .../reference/statements/const/index.md | 2 +- .../javascript/reference/statements/index.md | 24 ++++++++++++++++--- .../reference/statements/label/index.md | 2 +- .../reference/statements/let/index.md | 2 +- 8 files changed, 46 insertions(+), 10 deletions(-) diff --git a/files/en-us/web/javascript/reference/functions/arrow_functions/index.md b/files/en-us/web/javascript/reference/functions/arrow_functions/index.md index 47f6cd71b8d47d6..7a74c47bdb097ba 100644 --- a/files/en-us/web/javascript/reference/functions/arrow_functions/index.md +++ b/files/en-us/web/javascript/reference/functions/arrow_functions/index.md @@ -329,7 +329,7 @@ const func4 = ( ### Precedence of arrow -Although the arrow in an arrow function is not an operator, arrow functions have special parsing rules that interact differently with [operator precedence](/en-US/docs/Web/JavaScript/Reference/Operators/Operator_precedence) compared to regular functions. +Although the arrow in an arrow function is [not an operator](/en-US/docs/Web/JavaScript/Reference/Operators#what_are_operators), arrow functions have special parsing rules that interact differently with [operator precedence](/en-US/docs/Web/JavaScript/Reference/Operators/Operator_precedence) compared to regular functions. ```js-nolint example-bad let callback; diff --git a/files/en-us/web/javascript/reference/lexical_grammar/index.md b/files/en-us/web/javascript/reference/lexical_grammar/index.md index c2b4deddbd85fd4..704aa8e5ab462b5 100644 --- a/files/en-us/web/javascript/reference/lexical_grammar/index.md +++ b/files/en-us/web/javascript/reference/lexical_grammar/index.md @@ -604,7 +604,7 @@ for ( ) {} ``` -Semicolons are also never inserted as [empty statements](/en-US/docs/Web/JavaScript/Reference/Statements/Empty). For example, in the code below, if a semicolon is inserted after ")", then the code would be valid, with an empty statement as the `if` body and the `const` declaration being a separate statement. However, because automatically inserted semicolons cannot become empty statements, this causes a [declaration](/en-US/docs/Web/JavaScript/Reference/Statements#difference_between_statements_and_declarations) to become the body of the `if` statement, which is not valid. +Semicolons are also never inserted as [empty statements](/en-US/docs/Web/JavaScript/Reference/Statements/Empty). For example, in the code below, if a semicolon is inserted after ")", then the code would be valid, with an empty statement as the `if` body and the `const` declaration being a separate statement. However, because automatically inserted semicolons cannot become empty statements, this causes a [declaration](/en-US/docs/Web/JavaScript/Reference/Statements#what_are_statements_declarations_and_expressions) to become the body of the `if` statement, which is not valid. ```js-nolint example-bad if (Math.random() > 0.5) diff --git a/files/en-us/web/javascript/reference/operators/index.md b/files/en-us/web/javascript/reference/operators/index.md index d51807bdbe3adfe..84bdfad6de3ae9d 100644 --- a/files/en-us/web/javascript/reference/operators/index.md +++ b/files/en-us/web/javascript/reference/operators/index.md @@ -129,7 +129,7 @@ A comparison operator compares its operands and returns a boolean value based on - : The `in` operator determines whether an object has a given property. > [!NOTE] -> `=>` is not an operator, but the notation for [Arrow functions](/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions). +> `=>` is [not an operator](#what_are_operators), but the notation for [Arrow functions](/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions). ### Equality operators @@ -238,6 +238,24 @@ An assignment operator assigns a value to its left operand based on the value of - {{jsxref("Operators/Comma_operator", ",")}} - : The comma operator allows multiple expressions to be evaluated in a single statement and returns the result of the last expression. +## What are operators? + +As the [What are statements, declarations, and expressions?](/en-US/docs/Web/JavaScript/Reference/Statements#what_are_statements_declarations_and_expressions) section explains, an expression is a fundamental building block that evaluates to a value. Statements, declarations, and expressions can all define specific slots where expressions are accepted. Where an expression contains slots for further nested expressions, the part(s) that are not slots are known as operators. + +For example, the syntax for an [addition](/en-US/docs/Web/JavaScript/Reference/Operators/Addition) expression is `expression + expression` (if you read the spec, the operands are called _AdditiveExpression_ and _MultiplicativeExpression_, which are both subsets of _Expression_, but that's the spec's mechanism for defining [precedence and associativity](/en-US/docs/Web/JavaScript/Reference/Operators/Operator_precedence) and is irrelevant for our purposes). Apart from the two expression slots, the code entity it introduces is just `+`: the _addition operator_. Similarly, the syntax for a [yield](/en-US/docs/Web/JavaScript/Reference/Operators/yield) expression is `yield expression`, so `yield` is known as the operator. In other words, each operator corresponds to an expression. + +MDN also regards expressions without slots such as [`null`](/en-US/docs/Web/JavaScript/Reference/Operators/null) as operators per the definition above, although we nearly always just refer to them as "syntax" or "expression". + +An expression does not need to take a fixed number of slots. For example, the array literal expression, `[expression, expression, expression]`, can take an arbitrary number of expression slots. The `[,,]` part might be called an "operator". MDN avoids this usage, but you may see it in functional programming languages like [Haskell](https://www.haskell.org/onlinereport/haskell2010/haskellch3.html). + +The definition of operators gets fuzzier with certain other code entities: what if an expression has a slot that's not an expression, or a code entity combined with an expression does not make an expression? Do we still refer to that code entity as an operator? + +- In the [optional chaining](/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining) expression `foo?.bar`, `foo` is an expression, but `bar` must be an identifier and is not evaluated to a value. Do we still regard `?.` as an operator? +- In the [arrow function](/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions) expression `arg => body`, `body` might be an expression (although it can also be a block body), and `arg` is just an argument list. Do we still regard `=>` as an operator? +- In the [spread syntax](/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax) `...foo`, `foo` is an expression, but the whole thing is not an expression because it does not evaluate to a value—it only makes sense in certain other expressions like function calls, array literals, and object literals. Do we still regard `...` as an operator? + +The term "operator" is not precisely defined in JavaScript, so MDN does not give a definitive answer. Our approach is to group all these constructs under "Operators" but avoid formally referring to them as operators. Many useful concepts about operators, such as [precedence](/en-US/docs/Web/JavaScript/Reference/Operators/Operator_precedence), still apply to them regardless of their exact nature. + ## Specifications {{Specifications}} diff --git a/files/en-us/web/javascript/reference/operators/operator_precedence/index.md b/files/en-us/web/javascript/reference/operators/operator_precedence/index.md index 6e954a540b01171..4225850111f9abe 100644 --- a/files/en-us/web/javascript/reference/operators/operator_precedence/index.md +++ b/files/en-us/web/javascript/reference/operators/operator_precedence/index.md @@ -240,7 +240,7 @@ The following table lists operators in order from highest precedence (18) to low Several general notes about the table: -1. Not all syntax included here are "operators" in the strict sense. For example, spread `...` and arrow `=>` are typically not regarded as operators. However, we still included them to show how tightly they bind compared to other operators/expressions. +1. Not all syntax included here are ["operators" in the strict sense](/en-US/docs/Web/JavaScript/Reference/Operators#what_are_operators). For example, spread `...` and arrow `=>` are typically not regarded as operators. However, we still included them to show how tightly they bind compared to other operators/expressions. 2. Some operators have certain operands that require expressions narrower than those produced by higher-precedence operators. For example, the right-hand side of member access `.` (precedence 17) must be an identifier instead of a grouped expression. The left-hand side of arrow `=>` (precedence 2) must be an arguments list or a single identifier instead of some random expression. 3. Some operators have certain operands that accept expressions wider than those produced by higher-precedence operators. For example, the bracket-enclosed expression of bracket notation `[ … ]` (precedence 17) can be any expression, even comma (precedence 1) joined ones. These operators act as if that operand is "automatically grouped". In this case we will omit the associativity. diff --git a/files/en-us/web/javascript/reference/statements/const/index.md b/files/en-us/web/javascript/reference/statements/const/index.md index 0c72a43af7b49ec..37a98d7172583dd 100644 --- a/files/en-us/web/javascript/reference/statements/const/index.md +++ b/files/en-us/web/javascript/reference/statements/const/index.md @@ -46,7 +46,7 @@ The `const` declaration is very similar to {{jsxref("Statements/let", "let")}}: - `const` declarations can only be accessed after the place of declaration is reached (see [temporal dead zone](/en-US/docs/Web/JavaScript/Reference/Statements/let#temporal_dead_zone_tdz)). For this reason, `const` declarations are commonly regarded as [non-hoisted](/en-US/docs/Glossary/Hoisting). - `const` declarations do not create properties on {{jsxref("globalThis")}} when declared at the top level of a script. - `const` declarations cannot be [redeclared](/en-US/docs/Web/JavaScript/Reference/Statements/let#redeclarations) by any other declaration in the same scope. -- `const` begins [_declarations_, not _statements_](/en-US/docs/Web/JavaScript/Reference/Statements#difference_between_statements_and_declarations). That means you cannot use a lone `const` declaration as the body of a block (which makes sense, since there's no way to access the variable). +- `const` begins [_declarations_, not _statements_](/en-US/docs/Web/JavaScript/Reference/Statements#what_are_statements_declarations_and_expressions). That means you cannot use a lone `const` declaration as the body of a block (which makes sense, since there's no way to access the variable). ```js-nolint example-bad if (true) const a = 1; // SyntaxError: Lexical declaration cannot appear in a single-statement context diff --git a/files/en-us/web/javascript/reference/statements/index.md b/files/en-us/web/javascript/reference/statements/index.md index 47c1deaa8f04bf2..71dd144b21ca91f 100644 --- a/files/en-us/web/javascript/reference/statements/index.md +++ b/files/en-us/web/javascript/reference/statements/index.md @@ -6,7 +6,7 @@ browser-compat: javascript.statements sidebar: jssidebar --- -JavaScript applications consist of statements with an appropriate syntax. A single statement may span multiple lines. Multiple statements may occur on a single line if each statement is separated by a semicolon. This isn't a keyword, but a group of keywords. +JavaScript code is built from statements and declarations, which can contain expressions. This reference groups the constructs used to control execution and declare bindings. A statement can span multiple lines, and a line can contain multiple statements. ## Statements and declarations by category @@ -89,12 +89,16 @@ For an alphabetical listing see the sidebar on the left. - {{jsxref("Statements/with", "with")}} {{deprecated_inline}} - : Extends the scope chain for a statement. -## Difference between statements and declarations +## What are statements, declarations, and expressions? -In this section, we will be mixing two kinds of constructs: [_statements_](https://tc39.es/ecma262/multipage/ecmascript-language-statements-and-declarations.html#prod-Statement) and [_declarations_](https://tc39.es/ecma262/multipage/ecmascript-language-statements-and-declarations.html#prod-Declaration). They are two disjoint sets of grammars. The following are declarations: +All JavaScript programs are composed of a sequence of top-level constructs, using one of the syntaxes listed above. These are known as [_statements_](https://tc39.es/ecma262/multipage/ecmascript-language-statements-and-declarations.html#prod-Statement) and [_declarations_](https://tc39.es/ecma262/multipage/ecmascript-language-statements-and-declarations.html#prod-Declaration). In MDN docs, we often colloquially refer to both as _statements_, but they are technically two disjoint sets of grammars. + +The following are declarations: - {{jsxref("Statements/let", "let")}} - {{jsxref("Statements/const", "const")}} +- {{jsxref("Statements/using", "using")}} +- {{jsxref("Statements/await_using", "await using")}} - {{jsxref("Statements/function", "function")}} - {{jsxref("Statements/function*", "function*")}} - {{jsxref("Statements/async_function", "async function")}} @@ -151,6 +155,20 @@ if (condition) { } ``` +In JavaScript, statements and declarations produce values, but these values are almost never observable (other than {{jsxref("Global_Objects/eval", "eval()")}}). Their purpose is to manipulate the surrounding environment and produce side effects—creating variable bindings, outputting things, modifying variable values, etc. The values they use come from evaluating [_expressions_](https://tc39.es/ecma262/multipage/ecmascript-language-expressions.html#prod-Expression). + +Expressions are not top-level constructs; they can only be used in specific slots inside statements and declarations, such as `if (expression)`, `const x = expression`, etc. The [expression statement](/en-US/docs/Web/JavaScript/Reference/Statements/Expression_statement) syntax allows most expressions to be used as statements, but that's just a statement with a single expression slot. + +You can map out JavaScript syntax structures using just statements, declarations, and expressions: + +- Statements can contain statements, declarations, and expressions (like `if (expression) statement` and block statements `{ statement; declaration }`) +- Declarations can contain statements, declarations, and expressions (like `function x() { statement; declaration }` and `const x = expression`) +- Expressions can contain statements, declarations, and expressions (like `() => { statement; declaration }` and `console.log(expression)`) + +In the reference documentation for each piece of syntax, we describe all its "slots" and say whether each slot is a statement, declaration, or expression. + +_Operators_ is another important concept in JavaScript grammar, but they do not work like building blocks. See [What are operators?](/en-US/docs/Web/JavaScript/Reference/Operators#what_are_operators) for more information. + ## Browser compatibility {{Compat}} diff --git a/files/en-us/web/javascript/reference/statements/label/index.md b/files/en-us/web/javascript/reference/statements/label/index.md index ff1e84f191a92b7..f428bc81d1f788b 100644 --- a/files/en-us/web/javascript/reference/statements/label/index.md +++ b/files/en-us/web/javascript/reference/statements/label/index.md @@ -227,7 +227,7 @@ console.log("swap"); ### Labeled function declarations -Labels can only be applied to [statements, not declarations](/en-US/docs/Web/JavaScript/Reference/Statements#difference_between_statements_and_declarations). There is a legacy grammar that allows function declarations to be labeled in non-strict code: +Labels can only be applied to [statements, not declarations](/en-US/docs/Web/JavaScript/Reference/Statements#what_are_statements_declarations_and_expressions). There is a legacy grammar that allows function declarations to be labeled in non-strict code: ```js L: function F() {} diff --git a/files/en-us/web/javascript/reference/statements/let/index.md b/files/en-us/web/javascript/reference/statements/let/index.md index 9db51fea1e0231f..4435425c80fd4da 100644 --- a/files/en-us/web/javascript/reference/statements/let/index.md +++ b/files/en-us/web/javascript/reference/statements/let/index.md @@ -63,7 +63,7 @@ Compared with {{jsxref("Statements/var", "var")}}, `let` declarations have the f - `let` declarations can only be accessed after the place of declaration is reached (see [temporal dead zone](#temporal_dead_zone_tdz)). For this reason, `let` declarations are commonly regarded as [non-hoisted](/en-US/docs/Glossary/Hoisting). - `let` declarations do not create properties on {{jsxref("globalThis")}} when declared at the top level of a script. - `let` declarations cannot be [redeclared](#redeclarations) by any other declaration in the same scope. -- `let` begins [_declarations_, not _statements_](/en-US/docs/Web/JavaScript/Reference/Statements#difference_between_statements_and_declarations). That means you cannot use a lone `let` declaration as the body of a block (which makes sense, since there's no way to access the variable). +- `let` begins [_declarations_, not _statements_](/en-US/docs/Web/JavaScript/Reference/Statements#what_are_statements_declarations_and_expressions). That means you cannot use a lone `let` declaration as the body of a block (which makes sense, since there's no way to access the variable). ```js-nolint example-bad if (true) let a = 1; // SyntaxError: Lexical declaration cannot appear in a single-statement context From 3d04bc6079a6b9d051c72c465a6e0421f20f603c Mon Sep 17 00:00:00 2001 From: Hamish Willee Date: Sat, 5 Sep 2026 03:09:09 +1000 Subject: [PATCH 04/10] Express connection logic didn't catch failed connections (#45492) * Fix connection logic that didn't catch failed connections * Also gate HTTP server start on successful MongoDB connection The bin/www generated by express-generator starts the HTTP server unconditionally, so simply fixing the connectMongoose() try/catch logic wasn't enough: readers following the tutorial would still end up with a server that starts regardless of whether the database connected. Move server creation into a startServer() function that only runs once connectMongoose() resolves, matching the upstream fix in mdn/express-locallibrary-tutorial#367. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_018BoWRns9KXjAdyMZMeQ4g2 --------- Co-authored-by: Claude Sonnet 5 Co-authored-by: Joshua Chen --- .../express_nodejs/mongoose/index.md | 51 +++++++++++++++++-- 1 file changed, 46 insertions(+), 5 deletions(-) diff --git a/files/en-us/learn_web_development/extensions/server-side/express_nodejs/mongoose/index.md b/files/en-us/learn_web_development/extensions/server-side/express_nodejs/mongoose/index.md index d394c7923739057..423afa503c27e7d 100644 --- a/files/en-us/learn_web_development/extensions/server-side/express_nodejs/mongoose/index.md +++ b/files/en-us/learn_web_development/extensions/server-side/express_nodejs/mongoose/index.md @@ -679,6 +679,13 @@ const mongoose = require("mongoose"); const mongoDB = "insert_your_database_url_here"; +connectMongoose() + .then(startServer) + .catch((err) => { + console.error("Failed to connect to MongoDB:", err); + process.exit(1); + }); + async function connectMongoose() { await mongoose.connect(mongoDB); @@ -691,14 +698,48 @@ async function connectMongoose() { console.warn("MongoDB disconnected"); }); } - -connectMongoose().catch((err) => { - console.error("Failed to connect to MongoDB:", err); - process.exit(1); -}); ``` As discussed in the [Mongoose primer](#connecting_to_mongodb) above, this code creates the default connection to the database and reports any errors to the console. +It also calls a `startServer()` function once the connection succeeds, which we'll create next. + +The generated **bin/www** file creates the HTTP server and starts it listening immediately, regardless of whether the database connection succeeds. +Find this code, further down in the same file: + +```js +/** + * Create HTTP server. + */ + +var server = http.createServer(app); + +/** + * Listen on provided port, on all network interfaces. + */ + +server.listen(port); +server.on("error", onError); +server.on("listening", onListening); +``` + +Replace it with the following, which moves server creation and listening into a `startServer()` function so that it only runs once `connectMongoose()` has resolved: + +```js +/** + * Create HTTP server and listen on provided port, on all network + * interfaces, once the MongoDB connection is established. + */ + +var server; + +function startServer() { + server = http.createServer(app); + + server.listen(port); + server.on("error", onError); + server.on("listening", onListening); +} +``` > [!NOTE] > We could have put the database connection code in our **app.js** code. From f542ed344953b3312fc92150bba11536667e288a Mon Sep 17 00:00:00 2001 From: Husam Date: Fri, 4 Sep 2026 20:14:39 +0300 Subject: [PATCH 05/10] Use number of and fewer with countable nouns (#45498) --- .../extensions/performance/html/index.md | 2 +- .../soft_skills/workflows_and_processes/index.md | 2 +- .../en-us/web/api/canvas_api/tutorial/drawing_shapes/index.md | 2 +- files/en-us/web/api/characterdata/index.md | 4 ++-- files/en-us/web/api/htmltablesectionelement/index.md | 2 +- files/en-us/web/api/namednodemap/index.md | 2 +- files/en-us/web/api/progressevent/index.md | 2 +- files/en-us/web/api/progressevent/loaded/index.md | 2 +- files/en-us/web/api/progressevent/progressevent/index.md | 2 +- files/en-us/web/api/progressevent/total/index.md | 2 +- files/en-us/web/api/waveshapernode/oversample/index.md | 4 ++-- files/en-us/web/api/window/moveby/index.md | 4 ++-- files/en-us/web/api/xrsession/requesthittestsource/index.md | 2 +- .../xrsession/requesthittestsourcefortransientinput/index.md | 2 +- files/en-us/web/http/reference/headers/keep-alive/index.md | 2 +- .../reference/global_objects/bigint/asintn/index.md | 2 +- .../reference/global_objects/bigint/asuintn/index.md | 2 +- files/en-us/web/svg/reference/attribute/dx/index.md | 4 ++-- files/en-us/web/svg/reference/attribute/dy/index.md | 4 ++-- .../en-us/webassembly/reference/control_flow/return/index.md | 2 +- files/en-us/webassembly/reference/numeric/clz/index.md | 2 +- files/en-us/webassembly/reference/numeric/ctz/index.md | 2 +- files/en-us/webassembly/reference/numeric/index.md | 4 ++-- 23 files changed, 29 insertions(+), 29 deletions(-) diff --git a/files/en-us/learn_web_development/extensions/performance/html/index.md b/files/en-us/learn_web_development/extensions/performance/html/index.md index 0ea7c0c0d086722..61c0936dedee0de 100644 --- a/files/en-us/learn_web_development/extensions/performance/html/index.md +++ b/files/en-us/learn_web_development/extensions/performance/html/index.md @@ -44,7 +44,7 @@ To do this, you need to [measure the performance](/en-US/docs/Learn_web_developm HTML is simple in terms of performance — it is mostly text, which is small in size, and therefore, mostly quick to download and render. The key issues that can impact the performance of a web page include: -- Size of the image and video files: It is important to consider how to handle the content of replaced elements such as {{htmlelement("img")}} and {{htmlelement("video")}}. Image and video files are large and can add significantly to the weight of the page. Therefore, it is important to minimize the amount of bytes that get downloaded on a user's device (for example, serve smaller images for mobile). You also need to consider improving the perceived performance by loading images and videos on a page only when they are needed. +- Size of the image and video files: It is important to consider how to handle the content of replaced elements such as {{htmlelement("img")}} and {{htmlelement("video")}}. Image and video files are large and can add significantly to the weight of the page. Therefore, it is important to minimize the number of bytes that get downloaded on a user's device (for example, serve smaller images for mobile). You also need to consider improving the perceived performance by loading images and videos on a page only when they are needed. - Delivery of embedded content: This is usually the content embedded in {{htmlelement("iframe")}} elements. Loading content into `