Skip to content

Add --ignore-lock flag support to astro preview - #17767

Merged
ematipico merged 3 commits into
mainfrom
factory/fix-17720
Sep 2, 2026
Merged

ematipico merged 3 commits into
mainfrom
factory/fix-17720

Conversation

@astro-factory

@astro-factory astro-factory Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

When Astro 7.2 introduced the lock file mechanism for astro preview (PR #17174), it did not include a way to bypass the lock check. When --ignore-lock was subsequently added for astro dev (PR #17331), it was not extended to astro preview. This meant that users running multiple simultaneous preview servers (e.g., in Playwright E2E test setups) would always hit the "Another astro preview server is already running" error, with no workaround.

What Changed

  • Extends --ignore-lock support to packages/astro/src/cli/preview/index.ts, reusing the existing isIgnoreLock() helper from the dev module.
  • Adds conflict detection: --ignore-lock is rejected when combined with --force or --background, mirroring the dev server behavior.
  • When --ignore-lock is set, the lock file check and write are skipped, allowing multiple preview servers to run simultaneously on different ports.
  • Adds --ignore-lock to the preview --help output.
  • Includes a unit test (packages/astro/test/units/preview/ignore-lock-flag.test.ts) and a patch changeset.

Confirmation

@ematipico confirmed the fix: "The preview seems to be working".

Closes #17720

Docs

Needs a docs PR for the new flag

@astro-factory astro-factory Bot added the fix verified Reporter confirmed the triage bot fix works label Aug 20, 2026
@changeset-bot

changeset-bot Bot commented Aug 20, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 071cd92

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

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

@github-actions github-actions Bot added the pkg: astro Related to the core `astro` package (scope) label Aug 20, 2026
@github-actions github-actions Bot added the semver: minor Change triggers a `minor` release label Aug 20, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This PR is blocked because it contains a minor changeset. A reviewer will merge this at the next release if approved.

@codspeed

codspeed Bot commented Aug 20, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 21 untouched benchmarks


Comparing factory/fix-17720 (071cd92) with main (21c34a6)

Open in CodSpeed

@ArmandPhilippot

Copy link
Copy Markdown
Member

I opened a docs PR for this: withastro/docs#14489 (mostly reorganization since we already had some content because of astro dev)

@ematipico
ematipico merged commit ce7c91f into main Sep 2, 2026
46 of 47 checks passed
@ematipico
ematipico deleted the factory/fix-17720 branch September 2, 2026 12:45
@astrobot-houston astrobot-houston mentioned this pull request Sep 2, 2026
dadezzz pushed a commit to dadezzz/university_notes that referenced this pull request Sep 9, 2026
This PR contains the following updates:

| Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [astro](https://astro.build) ([source](https://github.com/withastro/astro/tree/HEAD/packages/astro)) | [`7.2.10` → `7.3.1`](https://renovatebot.com/diffs/npm/astro/7.2.10/7.3.1) | ![age](https://developer.mend.io/api/mc/badges/age/npm/astro/7.3.1?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/astro/7.2.10/7.3.1?slim=true) |

---

### Release Notes

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

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

[Compare Source](https://github.com/withastro/astro/compare/[email protected]@7.3.1)

##### Patch Changes

- [#&#8203;17899](withastro/astro#17899) [`0389640`](withastro/astro@0389640) Thanks [@&#8203;ematipico](https://github.com/ematipico)! - Fixes an error that prevented projects using `astro:assets` from starting or building

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

[Compare Source](https://github.com/withastro/astro/compare/[email protected]@7.3.0)

##### Minor Changes

- [#&#8203;17767](withastro/astro#17767) [`ce7c91f`](withastro/astro@ce7c91f) Thanks [@&#8203;astro-factory](https://github.com/apps/astro-factory)! - Adds `--ignore-lock` flag to `astro preview`, allowing multiple preview servers to run simultaneously on different ports. This is useful for E2E testing workflows (e.g., Playwright) that need to run several preview servers at once.

- [#&#8203;17818](withastro/astro#17818) [`c0b6581`](withastro/astro@c0b6581) Thanks [@&#8203;florian-lefebvre](https://github.com/florian-lefebvre)! - Adds a `logger` parameter to image services hooks

  Custom image services now receive Astro's runtime logger as an extra argument. Messages logged with it are routed through the destination configured in `logger` and respect your log level, instead of being written straight to the console:

  ```ts
  import type { LocalImageService } from 'astro';

  const service: LocalImageService = {
    // ...
    async transform(inputBuffer, transform, imageConfig, logger) {
      logger.warn(`Could not optimize "${transform.src}". Passing it through unchanged.`);
      return { data: inputBuffer, format: 'png' };
    },
  };
  ```

  Astro's built-in Sharp service now uses this logger for the warnings it emits when it encounters an unexpected or unsupported source format.

- [#&#8203;17818](withastro/astro#17818) [`c0b6581`](withastro/astro@c0b6581) Thanks [@&#8203;florian-lefebvre](https://github.com/florian-lefebvre)! - Adds `logger` to the context object passed to cache providers

  Custom cache providers now receive Astro's runtime logger on the context passed to `onRequest()`. Messages logged with it are routed through the destination configured in `logger` and respect your log level, instead of being written straight to the console:

  ```ts
  import type { CacheProvider } from 'astro';

  const provider: CacheProvider = {
    name: 'my-cache',
    async onRequest({ request, url, logger }, next) {
      logger.warn(`Skipping cache for ${url.pathname} because the response sets a cookie.`);
      return next();
    },
    // ...
  };
  ```

  Astro's built-in `memoryCache()` provider now uses this logger for the warnings it emits when it skips caching a response that sets cookies, and when a background revalidation fails.

##### Patch Changes

- [#&#8203;17818](withastro/astro#17818) [`c0b6581`](withastro/astro@c0b6581) Thanks [@&#8203;florian-lefebvre](https://github.com/florian-lefebvre)! - Updates Astro's remaining internal warnings and errors to be written through the configured logger instead of directly to the console, when possible

- [#&#8203;17886](withastro/astro#17886) [`e747cba`](withastro/astro@e747cba) Thanks [@&#8203;matthewp](https://github.com/matthewp)! - Fixes the memory cache provider to skip responses with `Vary: Cookie` or `Vary: *`

- [#&#8203;17885](withastro/astro#17885) [`916b738`](withastro/astro@916b738) Thanks [@&#8203;Princesseuh](https://github.com/Princesseuh)! - Improves build performance for sites with a large number of pages coming from a large amount of different modules.

- [#&#8203;17795](withastro/astro#17795) [`15e2deb`](withastro/astro@15e2deb) Thanks [@&#8203;matthewp](https://github.com/matthewp)! - Adds concurrent rendering support for `experimental.incrementalBuild`, including when using `@astrojs/cloudflare`

  Incremental builds no longer disable caching when `build.concurrency` is greater than `1`. Projects that set `build.concurrency: 1` to keep the cache enabled can remove that workaround. Cloudflare builds also reduce serialization overhead for large prerendered pages.

- [#&#8203;17879](withastro/astro#17879) [`21c34a6`](withastro/astro@21c34a6) Thanks [@&#8203;matthewp](https://github.com/matthewp)! - Fixes missing styles, links, and scripts from content collection entries rendered inside server islands

- [#&#8203;17861](withastro/astro#17861) [`3193988`](withastro/astro@3193988) Thanks [@&#8203;ethanstoner](https://github.com/ethanstoner)! - Fixes i18n fallback routes being generated with a corrupted path when the locale code also appears at the start of a later path segment. A page such as `src/pages/en/enterprise.astro` with `fallback: { es: 'en' }` produced the route `/es/esterprise` instead of `/es/enterprise`, so the fallback never matched the intended URL. Only the leading locale segment is rewritten now.

</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.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- 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:eyJjcmVhdGVkSW5WZXIiOiI0NC42NS41IiwidXBkYXRlZEluVmVyIjoiNDQuNjUuNSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix verified Reporter confirmed the triage bot fix works pkg: astro Related to the core `astro` package (scope) semver: minor Change triggers a `minor` release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot run multiple preview servers on Astro 7.2

3 participants