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

[InvalidImageService] error when calling getConfiguredImageService() at build time, but it works fine in dev mode #12902

Closed
1 task done
syakirurahman opened this issue Jan 6, 2025 · 3 comments
Labels
needs triage Issue needs to be triaged

Comments

@syakirurahman
Copy link

syakirurahman commented Jan 6, 2025

Astro Info

Astro                    v5.1.2
Node                     v18.19.1
System                   macOS (arm64)
Package Manager          pnpm
Output                   static
Adapter                  none
Integrations             @astrojs/tailwind
                         @astrojs/partytown
                         @astrojs/sitemap
                         astro-icon

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

This bug happened in my open-source headless wordpress template https://github.com/devaradise/slickpress, in this file https://github.com/devaradise/slickpress/blob/main/src/lib/node-utils.ts.

I'm trying to programmatically optimize images inside htmlString returned from wordpress posts by using getImage function from astro:assets. It works fine in dev mode, but when i tested to build, this error happened. I did initial investigation, and found out that getConfiguredImageService that is called inside getImage function return [InvalidImageService] service error.

Here is the stacktrace:

InvalidImageService: There was an error loading the configured image service. Please see the stack trace for more information.
    at eval (/Volumes/Work/Devaradise/headlesswp/slickpress-lite/node_modules/.pnpm/[email protected][email protected]/node_modules/astro/dist/assets/internal.js:25:21)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async getConfiguredImageService (/Volumes/Work/Devaradise/headlesswp/slickpress-lite/node_modules/.pnpm/[email protected][email protected]/node_modules/astro/dist/assets/internal.js:21:34)
    at async optimizeImagesInsideHtmlString (/Volumes/Work/Devaradise/headlesswp/slickpress-lite/src/lib/node-utils.ts:12:26)
    at async Object.load (/Volumes/Work/Devaradise/headlesswp/slickpress-lite/src/lib/wp-loader.ts:64:36)
    at async Promise.all (index 0)
    at async #doSync (file:///Volumes/Work/Devaradise/headlesswp/slickpress-lite/node_modules/.pnpm/[email protected][email protected]/node_modules/astro/dist/content/content-layer.js:152:5)
    at async file:///Volumes/Work/Devaradise/headlesswp/slickpress-lite/node_modules/.pnpm/[email protected]/node_modules/p-queue/dist/index.js:187:36 {
  loc: undefined,
  title: 'Error while loading image service.',
  hint: undefined,
  frame: undefined,
  type: 'AstroError',
  cause: Error: Vite module runner has been closed.
      at SSRCompatModuleRunner.getModuleInformation (file:///Volumes/Work/Devaradise/headlesswp/slickpress-lite/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/module-runner.js:1196:13)
      at SSRCompatModuleRunner.cachedModule (file:///Volumes/Work/Devaradise/headlesswp/slickpress-lite/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/module-runner.js:1186:21)
      at request (file:///Volumes/Work/Devaradise/headlesswp/slickpress-lite/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/module-runner.js:1222:99)
      at dynamicRequest (file:///Volumes/Work/Devaradise/headlesswp/slickpress-lite/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/module-runner.js:1224:124)
      at getConfiguredImageService (/Volumes/Work/Devaradise/headlesswp/slickpress-lite/node_modules/.pnpm/[email protected][email protected]/node_modules/astro/dist/assets/internal.js:21:40)
      at optimizeImagesInsideHtmlString (/Volumes/Work/Devaradise/headlesswp/slickpress-lite/src/lib/node-utils.ts:12:83)
      at Object.load (/Volumes/Work/Devaradise/headlesswp/slickpress-lite/src/lib/wp-loader.ts:64:98)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async Promise.all (index 0)
      at async #doSync (file:///Volumes/Work/Devaradise/headlesswp/slickpress-lite/node_modules/.pnpm/[email protected][email protected]/node_modules/astro/dist/content/content-layer.js:152:5)
}

I'm using passthrough image service, but the the default image service also return the same error at build time.

What's the expected result?

Same behavior between build and dev mode.

Link to Minimal Reproducible Example

https://stackblitz.com/~/github.com/devaradise/slickpress

Edit

The image service in reproduction example seems not working entirely. But, since this is from open source project, all codes are publicly accessible and it has live demo here https://slickpress.headlesswp.io/.

It deployed to cloudflare pages. The live demo works fine because i handled the error from getConfiguredImageService and serve the original images instead. The post main images optimization is working fine because it use Astro <Image /> component directly.

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Jan 6, 2025
@ascorbic
Copy link
Contributor

ascorbic commented Jan 6, 2025

I'm closing this as it's a duplicate of #12689. I would recommend looking at how we handle images from markdown files in the glob loader though, as that's likely to be a better approach to image processing

@ascorbic ascorbic closed this as not planned Won't fix, can't repro, duplicate, stale Jan 6, 2025
@syakirurahman
Copy link
Author

Thank you @ascorbic

@syakirurahman
Copy link
Author

syakirurahman commented Jan 6, 2025

@ascorbic could you please share the reference to the image handling from markdown files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

2 participants