Repository navigation
Fix npm run lint and API requests that get no response - #613
Open
eabdullin1 wants to merge 2 commits into
Open
eabdullin1 wants to merge 2 commits into
eabdullin1 wants to merge 2 commits into
Conversation
Dependabot bumped ESLint to 9, which reads only flat configs by default, so "npm run lint" failed with "Invalid option '--ext'" on the .eslintrc.js of the project. ESLint 9 also needs Node.js 18.18+, while the Docker image used by CI and docker-compose runs Node.js 16.20. Go back to ESLint 8.57, which supports both, and keep the rules and plugins as they are. Tell Dependabot to skip ESLint major updates.
The response interceptor read error.response.status of every failed request, so a network error, a timeout or a cancelled request, which have no response, threw a TypeError inside the interceptor instead of rejecting with the axios error, and the user saw nothing. Move the handler to src/apiErrors.js and tell the user when the server cannot be reached or does not answer in time; stay silent for requests cancelled on purpose or aborted by the browser. The handler always rejects with the original error, and 401 and 403 work as before. Cover it with unit tests on the built-in Node.js test runner: npm test loads src/ as ES modules with a small loader hook, so it runs on the Node.js 16 of the Docker image as well.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
npm run lintfails on master withInvalid option '--ext': Dependabot bumped ESLint to 9, which reads only flat configs by default, while the project has.eslintrc.js. ESLint 9 also needs Node.js 18.18+, and the Docker image used by CI and docker-compose runs Node.js 16.20.src/boot/api.jsreadserror.response.statusof every failed request. A network error, a timeout or a cancelled request has no response, so the interceptor throws aTypeErrorinstead of rejecting with the axios error, and the user sees nothing.Changes
ESLint 8.57 instead of 9, rules and plugins unchanged.
npm run lintpasses (68 files, no errors or warnings) withoutESLINT_USE_FLAT_CONFIG. Dependabot skips ESLint major updates, so it doesn't bring 9 back before the image moves to a newer Node.js.Interceptor: the handler moved to
src/apiErrors.js.Notifications look like the other ones. The promise always rejects with the original error, 401 and 403 work as before. Prettier reformatted
src/boot/api.js.Unit tests on the built-in Node.js test runner (
npm test, no new packages): a small loader hook loadssrc/as ES modules, so the tests run on Node.js 16 as well. 10 tests run real axios with a stubbed adapter; 4 of them fail with the oldTypeErrorif the uncheckederror.response.statusis put back.Testing
Not changed
Many
.catchhandlers insrc/readerror.response.*themselves (e.g.getFromApiinsrc/utils.js). On a network error the user now gets a clear notification, but those handlers still throw aTypeErrorin the console. That is left for a separate change.🤖 Generated with Claude Code