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(config): improved warning when root path includes bad characters #15761

Merged
merged 12 commits into from
Feb 7, 2024
Merged

fix(config): improved warning when root path includes bad characters #15761

merged 12 commits into from
Feb 7, 2024

Conversation

poppa
Copy link
Contributor

@poppa poppa commented Jan 31, 2024

Previously a warning was only issued when the root path included the # character, but the ? character is equally bad.

Description

This should fix #15726.

Root paths can not include the # nor the ? character. ESM is using URLs to resolve imports, and in an URL what follows those characters is not part of the path.

Additional context

I saw there's another PR for this (#15755), but this PR is a bit more elaborative and includes some tests as well.


What is the purpose of this pull request?

  • Other

I would consider it an overall improvement.

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines, especially the Pull Request Guidelines.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

Previously a warning was only issued when the root path included the `#` character, but the `?` character is equally bad.
Copy link

stackblitz bot commented Jan 31, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@poppa poppa changed the title fix(config): Improved warning when root path includes bad characters fix(config): improved warning when root path includes bad characters Jan 31, 2024
poppa added 2 commits January 31, 2024 13:31
This is pretty much a dummy commit to get the CI checks to run again. The previous one failed, I would say, intermittently and unrelated to any code changes.
@poppa
Copy link
Contributor Author

poppa commented Feb 1, 2024

I can't see that the failing test on Windows has anything to do with this PR?

Run echo "PLAYWRIGHT_BROWSERS_PATH=$HOME\.cache\playwright-bin" >> $env:GITHUB_ENV
  echo "PLAYWRIGHT_BROWSERS_PATH=$HOME\.cache\playwright-bin" >> $env:GITHUB_ENV
  $env:PLAYWRIGHT_VERSION="$(pnpm ls --depth 0 --json -w playwright-chromium | jq --raw-output '.[0].devDependencies[\"playwright-chromium\"].version')"
  echo "PLAYWRIGHT_VERSION=$env:PLAYWRIGHT_VERSION" >> $env:GITHUB_ENV
  shell: C:\Program Files\PowerShell\7\pwsh.EXE -command ". '{0}'"
  env:
    NODE_OPTIONS: --max-old-space-size=6144
    PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
    VITEST_SEGFAULT_RETRY: 3
    PNPM_HOME: C:\Users\runneradmin\setup-pnpm\node_modules\.bin
jq: error: syntax error, unexpected INVALID_CHARACTER (Windows cmd shell quoting issues?) at <top-level>, line 1:
.[0].devDependencies[\"playwright-chromium\"].version                     
jq: 1 compile error
ResourceUnavailable: D:\a\_temp\af6fc96b-044b-47f4-a84e-a29f7ea013f2.ps1:3
Line |
   3 |  … _VERSION="$(pnpm ls --depth 0 --json -w playwright-chromium | jq --ra …
     |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Program 'pnpm.CMD' failed to run: The pipe is being closed.At
     | D:\a\_temp\af6fc96b-044b-47f4-a84e-a29f7ea013f2.ps1:3 char:28 + … HT_VERSION="$(pnpm ls --depth 0 --json -w
     | playwright-chromium | jq -- … +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.
Error: Process completed with exit code 1.

Build&Test broke on Windows with the following error:

```
jq: error: syntax error, unexpected INVALID_CHARACTER (Windows cmd shell quoting issues?) at <top-level>, line 1:
.[0].devDependencies[\"playwright-chromium\"].version
```

Seems strange this would break now since the escaped quotes had been there for at least 14 months.
@poppa
Copy link
Contributor Author

poppa commented Feb 1, 2024

I can't see that the failing test on Windows has anything to do with this PR?

[...]

Well, that was something unrelated, which I seem to have fixed.

@poppa
Copy link
Contributor Author

poppa commented Feb 1, 2024

So, how does this error happen?

"WebSocket server error: Port is already in use"

There seems to be some intermittent errors occuring in the test suite overall.

I get this intermittently when running the test suite locally:

 FAIL  playground/fs-serve/__tests__/base/fs-serve-base.spec.ts > main > safe fetch with query
AssertionError: expected '' to include 'KEY=safe'
 ❯ playground/fs-serve/__tests__/base/fs-serve-base.spec.ts:28:57

@bluwy bluwy added the p2-nice-to-have Not breaking anything but nice to have (priority) label Feb 6, 2024
bluwy
bluwy previously approved these changes Feb 7, 2024
$env:PLAYWRIGHT_VERSION="$(pnpm ls --depth 0 --json -w playwright-chromium | jq --raw-output '.[0].devDependencies[\"playwright-chromium\"].version')"
$env:PLAYWRIGHT_VERSION="$(pnpm ls --depth 0 --json -w playwright-chromium | jq --raw-output '.[0].devDependencies["playwright-chromium"].version')"
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for fixing this! The issue has been haunting us in CI for many weeks now.

patak-dev
patak-dev previously approved these changes Feb 7, 2024
Copy link
Member

@patak-dev patak-dev left a comment

Choose a reason for hiding this comment

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

Oh, nice!

const logger = createLogger('info')
logger.warn = (str) => {
expect(normalizeString(str)).toEqual(
'The project root contains the "?" character (/inc?udes), which may ' +
Copy link
Member

Choose a reason for hiding this comment

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

I think we may be introducing to many, too specific, tests here for this feature. I would be ok with a single one and to have a includes instead of equal test so we avoid having to maintain all this in sync if we later change the wording.

Copy link
Member

Choose a reason for hiding this comment

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

Agree 👍 I moved this as a unit test with only a single.

@patak-dev
Copy link
Member

@poppa would you do a quick PR only with this change to fix Windows CI? #15761. Better if we get that in a separate PR

@bluwy bluwy dismissed stale reviews from patak-dev and themself via 80b1bf4 February 7, 2024 09:20
Copy link
Member

@patak-dev patak-dev left a comment

Choose a reason for hiding this comment

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

ok, let's merge it so we can unblock CI for others

@patak-dev patak-dev merged commit 1c0dc3d into vitejs:main Feb 7, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2-nice-to-have Not breaking anything but nice to have (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Also warn when absolute file paths include ? during build (relates to #14165)
3 participants