Skip to content

fix: don't swallow the positional argument after --profile - #23033

Closed
shulaoda wants to merge 1 commit into
mainfrom
07-24-fix_don_t_swallow_the_positional_argument_after_--profile
Closed

shulaoda wants to merge 1 commit into
mainfrom
07-24-fix_don_t_swallow_the_positional_argument_after_--profile

Conversation

@shulaoda

Copy link
Copy Markdown
Member

fixes #23032

bin/vite.js strips --profile from process.argv before cac parses it, but it also removed the next non-flag token, as if the flag took a value. --profile never takes a value: the profiler is started unconditionally and no code reads a value for it. So the extra splice only swallowed real positionals. For example, vite --profile my-app silently started the dev server in the current directory instead of my-app, and vite --profile build started a dev server instead of building. Writing the flag after the positional was unaffected, which is why this went unnoticed.

No test is included: bin/vite.js has no existing test coverage and the change only deletes dead logic. Verified manually that vite build --profile <root> now builds <root> (the CPU profile is still written) and that the flag-last form behaves the same as before.

@bluwy

bluwy commented Jul 24, 2026

Copy link
Copy Markdown
Member

Hmm I suppose it took a value in case it needed it in the future, like for naming the profile file, just that it never done that. Do we want to consider possibly renaming the file then? Otherwise this change will cause a small breaking change. and if we decide later we want to accept a value, it'll cause another small breaking change.

@shulaoda

Copy link
Copy Markdown
Member Author

Hmm I suppose it took a value in case it needed it in the future, like for naming the profile file, just that it never done that. Do we want to consider possibly renaming the file then? Otherwise this change will cause a small breaking change. and if we decide later we want to accept a value, it'll cause another small breaking change.

Good point. I implemented this in a new PR, #23042.

BTW, it seems this behavior was introduced about five years ago, when Evan first implemented it: e312645

@sapphi-red

Copy link
Copy Markdown
Member

Closing in favor of #23042

@sapphi-red sapphi-red closed this Jul 28, 2026
@shulaoda
shulaoda deleted the 07-24-fix_don_t_swallow_the_positional_argument_after_--profile branch November 9, 2026 09:09
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.

--profile swallows the following positional argument (e.g. the root dir)

4 participants