fix(dev): treat missing ps row as stale in lockfile process check by okxint · Pull Request #18376 · withastro/astro · GitHub
Skip to content

fix(dev): treat missing ps row as stale in lockfile process check - #18376

Merged
Princesseuh merged 3 commits into
withastro:mainfrom
okxint:fix/lockfile-linux-thread-id
Oct 20, 2026
Merged

Princesseuh merged 3 commits into
withastro:mainfrom
okxint:fix/lockfile-linux-thread-id

Conversation

@okxint

@okxint okxint commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

Fixes #18343

On Linux, process.kill(pid, 0) succeeds for thread-ids, but ps -p <tid> returns no matching row. isLockFileProcessAlive was returning true (alive) when processInfo was undefined because processInfo?.cmd === undefined evaluates to true — so the function treated a thread-id lockfile entry as a live server.

This caused astro dev to refuse to start and, if the user force-cleared the lock, potentially send SIGTERM to an unrelated process that had recycled the same pid.

Fix: guard with an explicit undefined check — if ps returns no row the pid is not a running process, so the lock is stale.

// before
return processInfo?.cmd === undefined || isAstroCommand(processInfo.cmd)

// after
if (processInfo === undefined) return false
return isAstroCommand(processInfo.cmd)

On Linux, process.kill(pid, 0) succeeds for thread-ids, but ps -p <tid>
returns no matching row. isLockFileProcessAlive was returning true
(alive) when processInfo was undefined because the optional chain made
the undefined check pass. This caused astro dev to treat a recycled
thread-id as a live server, blocking startup and potentially sending
SIGTERM to an unrelated process.

Guard with an explicit undefined check: if ps returns no row, the pid
is not a running process and the lock is stale.

Fixes withastro#18343
@changeset-bot

changeset-bot Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

@github-actions github-actions Bot added the pkg: astro Related to the core `astro` package (scope) label Oct 14, 2026
@codspeed

codspeed Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Comment thread packages/astro/src/core/dev/lockfile.ts Outdated
@Princesseuh
Princesseuh merged commit a4e201d into withastro:main Oct 20, 2026
13 checks passed
@astrobot-houston astrobot-houston mentioned this pull request Oct 20, 2026
dadezzz pushed a commit to dadezzz/university_notes that referenced this pull request Oct 25, 2026
This PR contains the following updates:

| Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [@astrojs/check](https://github.com/withastro/astro/tree/main/packages/language-tools/astro-check) ([source](https://github.com/withastro/astro/tree/HEAD/packages/language-tools/astro-check)) | [`0.9.11` → `0.9.12`](https://renovatebot.com/diffs/npm/@astrojs%2fcheck/0.9.11/0.9.12) | ![age](https://developer.mend.io/api/mc/badges/age/npm/@astrojs%2fcheck/0.9.12?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@astrojs%2fcheck/0.9.11/0.9.12?slim=true) |
| [@astrojs/markdown-remark](https://astro.build) ([source](https://github.com/withastro/astro/tree/HEAD/packages/markdown/remark)) | [`7.3.3` → `7.3.4`](https://renovatebot.com/diffs/npm/@astrojs%2fmarkdown-remark/7.3.3/7.3.4) | ![age](https://developer.mend.io/api/mc/badges/age/npm/@astrojs%2fmarkdown-remark/7.3.4?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@astrojs%2fmarkdown-remark/7.3.3/7.3.4?slim=true) |
| [astro](https://astro.build) ([source](https://github.com/withastro/astro/tree/HEAD/packages/astro)) | [`7.4.1` → `7.4.2`](https://renovatebot.com/diffs/npm/astro/7.4.1/7.4.2) | ![age](https://developer.mend.io/api/mc/badges/age/npm/astro/7.4.2?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/astro/7.4.1/7.4.2?slim=true) |

---

### Release Notes

<details>
<summary>withastro/astro (@&#8203;astrojs/check)</summary>

### [`v0.9.12`](https://github.com/withastro/astro/blob/HEAD/packages/language-tools/astro-check/CHANGELOG.md#0912)

[Compare Source](https://github.com/withastro/astro/compare/@astrojs/check@0.9.11...@astrojs/check@0.9.12)

##### Patch Changes

- [#&#8203;18455](withastro/astro#18455) [`7af66fc`](withastro/astro@7af66fc) Thanks [@&#8203;astro-factory](https://github.com/apps/astro-factory)! - Fixes the `astro-check` binary ignoring its first two command-line arguments, so flags such as `--help`, `--root`, `--watch`, and `--tsconfig` are respected again. If your scripts padded the arguments to work around this (for example, `astro-check -- -- --tsconfig ./tsconfig.app.json`), remove the padding.
- Updated dependencies \[[`044148d`](withastro/astro@044148d)]:
  - [@&#8203;astrojs/language-server](https://github.com/astrojs/language-server)@2.17.3

</details>

<details>
<summary>withastro/astro (@&#8203;astrojs/markdown-remark)</summary>

### [`v7.3.4`](https://github.com/withastro/astro/blob/HEAD/packages/markdown/remark/CHANGELOG.md#734)

[Compare Source](https://github.com/withastro/astro/compare/@astrojs/markdown-remark@7.3.3...@astrojs/markdown-remark@7.3.4)

##### Patch Changes

- Updated dependencies \[[`cf27e70`](withastro/astro@cf27e70)]:
  - [@&#8203;astrojs/prism](https://github.com/astrojs/prism)@4.1.1

</details>

<details>
<summary>withastro/astro (astro)</summary>

### [`v7.4.2`](https://github.com/withastro/astro/blob/HEAD/packages/astro/CHANGELOG.md#742)

[Compare Source](https://github.com/withastro/astro/compare/astro@7.4.1...astro@7.4.2)

##### Patch Changes

- [#&#8203;18430](withastro/astro#18430) [`dda9ec3`](withastro/astro@dda9ec3) Thanks [@&#8203;Abhirup-99](https://github.com/Abhirup-99)! - Speeds up content sync with `experimental.collectionStorage: "chunked"` by computing each character's UTF-8 width from its code point instead of encoding every character through `TextEncoder`. On a store of \~44k entries this cuts the chunking step from about 60 seconds to well under a second, with byte-identical output.

- [#&#8203;18438](withastro/astro#18438) [`5e0eaa4`](withastro/astro@5e0eaa4) Thanks [@&#8203;astro-factory](https://github.com/apps/astro-factory)! - Fixes `astro dev` with `@astrojs/cloudflare` failing with ``Calling `require` for "node-fetch"`` when a server dependency such as `cross-fetch` requires `node-fetch`

- [#&#8203;18376](withastro/astro#18376) [`a4e201d`](withastro/astro@a4e201d) Thanks [@&#8203;okxint](https://github.com/okxint)! - Fixes `astro dev` treating a stale lock file containing a Linux thread ID as a running Astro server. A successful process lookup with no matching PID now marks the lock as stale, preventing `astro dev stop` and `astro dev --force` from killing the unrelated process that owns the thread.

- [#&#8203;18467](withastro/astro#18467) [`d1fb7d3`](withastro/astro@d1fb7d3) Thanks [@&#8203;astro-factory](https://github.com/apps/astro-factory)! - Fixes the `defineConfig()` types for `i18n.defaultLocale`, `i18n.fallback`, and `i18n.domains` so they accept a custom locale's `path` instead of its `codes`, matching how Astro validates and uses these values

- [#&#8203;18475](withastro/astro#18475) [`cf27e70`](withastro/astro@cf27e70) Thanks [@&#8203;ematipico](https://github.com/ematipico)! - Bumps the minimum supported Node.js version to 22.23.4, which includes the fixes from the [October 2026 Node.js security releases](https://nodejs.org/en/blog/vulnerability/october-2026-security-releases)

  This is a patch release because the [Node.js support and upgrade policy](https://docs.astro.build/en/upgrade-astro/#nodejs-support-and-upgrade-policies) allows the Core team to raise the minimum Maintenance LTS version in a patch release when a disclosed and fixed Node.js security flaw affects Astro.

- [#&#8203;18451](withastro/astro#18451) [`7a0ba6f`](withastro/astro@7a0ba6f) Thanks [@&#8203;DenisCDev](https://github.com/DenisCDev)! - Fixes `astro sync`, `astro check` and `astro build` replacing the optimized dependencies of a dev server running in the same project, which broke framework islands in that dev server until it was restarted with `--force`

- [#&#8203;18336](withastro/astro#18336) [`e943003`](withastro/astro@e943003) Thanks [@&#8203;astro-factory](https://github.com/apps/astro-factory)! - Fixes inline styles in dev so that framework-transformed CSS is used, such as scoped styles and `v-bind()` in Vue single-file components

- [#&#8203;18399](withastro/astro#18399) [`829fc00`](withastro/astro@829fc00) Thanks [@&#8203;astro-factory](https://github.com/apps/astro-factory)! - Fixes a dev server error (`Could not find server component name`) for a `server:defer` island that imports `astro:actions` or `astro:config/server`, when its page was not the first island page loaded after starting the server

- [#&#8203;18330](withastro/astro#18330) [`4db9e0d`](withastro/astro@4db9e0d) Thanks [@&#8203;Samuteg](https://github.com/Samuteg)! - Fixes the `astro:env/server` virtual module being generated with invalid JS in dev when any environment variable contains `$` replacement patterns (`` $` ``, `$&`, `$'`, `$1`, …). The inlined env JSON was passed as a string to `String.replace`, so e.g. the `KITTY_PUBLIC_KEY` value set by default in Kitty terminals corrupted the module and broke dev with `Failed to parse source for import analysis`

- Updated dependencies \[[`cf27e70`](withastro/astro@cf27e70)]:
  - [@&#8203;astrojs/telemetry](https://github.com/astrojs/telemetry)@3.4.1
  - [@&#8203;astrojs/markdown-satteri](https://github.com/astrojs/markdown-satteri)@0.4.5

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://github.com/renovatebot/renovate/discussions) if that's undesired.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4xODEuMSIsInVwZGF0ZWRJblZlciI6IjQ0LjE4MS4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: astro Related to the core `astro` package (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

astro dev takes a lock-file pid that is now a thread for a running server: refuses to start, and --force / stop kill the unrelated process

2 participants