Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix "Unknown fragment" validation error #3861

Merged
merged 4 commits into from
Mar 14, 2025

Conversation

motemen
Copy link
Contributor

@motemen motemen commented Feb 5, 2025

fixes #3620

Above error occurs because it tries to parse already-parsed GraphQL documents as languages like TypeScript or so. This PR fixes this behavior.

Copy link

changeset-bot bot commented Feb 5, 2025

🦋 Changeset detected

Latest commit: ec08bb7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
graphql-language-service-server Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

linux-foundation-easycla bot commented Feb 5, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@wenchienchen-asana
Copy link

@acao @dimaMachina apologies for the tag, but is there anything non-maintainers can do to help get this fix merged and released? I believe this fixes a longstanding issue that has prevented many people from using the latest version of the VS Code plugin. Thanks!

@VinceBT-BG
Copy link

@wenchienchen-asana Can you take a look at the two check errors ?

@wenchienchen-asana
Copy link

wenchienchen-asana commented Feb 21, 2025

I don't think they're related to this change... The Jest tests pass when I run them locally, so maybe they're flaky or there's some issue specific to the CI setup?

@acao
Copy link
Member

acao commented Feb 27, 2025

I am also getting test failures as well, it seems that there were some changes to to the integration tests since I last worked on them and they are failing for me locally and in CI here. The fs mocking appears to be the culprit, which can be quite flaky. Thus this nonsensical error, which was fixed last year:

  EEXIST, file already exists '/tmp/graphql-language-service'

      141 |
      142 |     if (!existsSync(this._tmpDirBase)) {
    > 143 |       void mkdirSync(this._tmpDirBase);
          |                     ^
      144 |     }
      145 |   }

The change makes sense, but I need to get these tests working, because these tests are already designed to test for this bug, if you see the other fragment related tests in this file!

update: good news!

it appears related to this issue:
tschaub/mock-fs#380

funny thing, in MessageProcessor.ts if i just change the existsSync import from node:fs to fs, the tests pass, including yours!

@dimaMachina are we going to run into runtime/build issues if we change from node:fs to fs to import in this one file? perhaps we should patch fs-mock if so?

@acao
Copy link
Member

acao commented Feb 27, 2025

@motemen I've confirmed the fix behaviorally, and the new test fails if I revert the change, looks awesome!

the fix for mock-fs should pass in CI i hope, the delta may be node version related

@acao
Copy link
Member

acao commented Feb 28, 2025

no dice on that fixing CI as you can see 😭
I hope to fix this over the weekend. hopefully it's just a node version issue. we may just replace the mock-fs impl with something more stable, as this should not be this hard 😆

I would otherwise just skip the test because this bug is so important to fix, but this integration suite is very important, so I need to give this my due diligence!

@acao
Copy link
Member

acao commented Mar 14, 2025

I am going to go ahead and merge this with a failing test, because this bugfix is more important than the test currently, and I can confirm that the new test works and confirms the bugfix. I will take care of solving this test bug as a follow up after the next release. thanks everyone for your patience, and @motemen for this fix!

motemen and others added 4 commits March 13, 2025 22:00
`mock-fs` uses `process.binding('fs')`, so it cannot support mocking the `node:fs` import alias it seems. this should fix test failures in CI (for node 22 at least)
@acao acao force-pushed the lsp-fix-unknown-fragment-3620 branch from 9975944 to ec08bb7 Compare March 14, 2025 02:00
@acao acao merged commit c5325dd into graphql:main Mar 14, 2025
10 of 12 checks passed
@acao acao mentioned this pull request Mar 14, 2025
@acao
Copy link
Member

acao commented Mar 14, 2025

oddly enough, the test passed here
https://github.com/graphql/graphiql/actions/runs/13848401899/job/38751280571?pr=3881

PASS graphql-language-service-server packages/graphql-language-service-server/src/__tests__/MessageProcessor.spec.ts (44.561 s)

either way, enjoy the latest release! thanks again!

@motemen
Copy link
Contributor Author

motemen commented Mar 14, 2025

Thank you!

@VinceBT-BG
Copy link

VinceBT-BG commented Mar 14, 2025

@acao Should it fix #3066 as well ?

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.

[lsp-server] 🐞 VSCode validation error Unknown fragment in v0.11.0
4 participants