Skip to content

Prevent configuration file "loading loop" when transpiling TS.#202

Merged
phryneas merged 7 commits into
mainfrom
pr/fix-ts-loading
Sep 17, 2024
Merged

Prevent configuration file "loading loop" when transpiling TS.#202
phryneas merged 7 commits into
mainfrom
pr/fix-ts-loading

Conversation

@phryneas
Copy link
Copy Markdown
Member

@phryneas phryneas commented Sep 13, 2024

This was also present in the original cosmiconfig loader logic, which would compile a apollo.config.ts to a apollo.config.mjs and then import from that file.

Problem with this is that that file creation (and deletion) would trigger the file event watcher, which then would trigger another config parse, leading to an infinite loop.
This didn't lead to particularly high system load, since it happened only every 2 seconds or so, with all the async layers involved, but it was definitely problematic.

We now create that file in a temporary directory outside the workspace, and we use apollo.config.ts.mjs, which is not a valid config file name and wouldn't lead to a loop even if picked up (e.g. if someone opens the system temp folder as a workspace).

Comment on lines -218 to -220
if (equal(project.config.rawConfig, config.rawConfig)) {
return;
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this logic when I saw that there were too many file events happening, but didn't know why and assumed the reason was something outside the scope of this Extension.

Removing it here again, since sometimes we actually want a restart even if the config didn't really change.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Sep 13, 2024

You can download the latest build of the extension for this PR here:
vscode-apollo-0.0.0-build-1726589621.pr-202.commit-2dabc63.zip.

To install the extension, download the file, unzip it and install it in VS Code by selecting "Install from VSIX..." in the Extensions view.

Alternatively, run

code --install-extension vscode-apollo-0.0.0-build-1726589621.pr-202.commit-2dabc63.vsix --force

from the command line.

For older builds, please see the edit history of this comment.

@phryneas phryneas marked this pull request as draft September 13, 2024 13:11
@phryneas
Copy link
Copy Markdown
Member Author

I've come to the conclusion that creating this file in another folder is not a good idea, since it would stop any imports from working... doing some changes.

@phryneas phryneas marked this pull request as ready for review September 13, 2024 14:11
@phryneas phryneas changed the title Prevent creation of a JS configuration file when transpiling TS. Prevent configuration file "loading loop" when transpiling TS. Sep 17, 2024
@phryneas phryneas merged commit ea5cc09 into main Sep 17, 2024
@phryneas phryneas deleted the pr/fix-ts-loading branch September 17, 2024 16:15
@github-actions github-actions Bot mentioned this pull request Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants