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(remote-storage): raise error if storage is not enabled in the deployment #68

Merged
merged 7 commits into from
Apr 12, 2024

Conversation

farnabaz
Copy link
Collaborator

@farnabaz farnabaz commented Apr 11, 2024

Screenshot 2024-04-11 at 16 07 54

Copy link

cloudflare-workers-and-pages bot commented Apr 11, 2024

Deploying nuxthub-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4f680e2
Status:⚡️  Build in progress...

View logs

@atinux
Copy link
Contributor

atinux commented Apr 11, 2024

  • Show a warning on startup
  • Checkout nuxt/assets for displaying message instead of statusMessage for better error handling on 500

@farnabaz
Copy link
Collaborator Author

farnabaz commented Apr 12, 2024

  • Checkout nuxt/assets for displaying message instead of statusMessage for better error handling on 500

As I checked, this is not related to nuxt/assets. This is more like ofetch behavior that reads statusText for error message. Since we raise error in API and fetching them in front, ofetch will convert the error and use statusMessage
https://github.com/unjs/ofetch/blob/5cc16a0d79e003c0418317987ca087032694b14f/src/error.ts#L30-L32

Here is a converted error

{
    "url": "/",
    "statusCode": 422,
    "statusMessage": "",
    "message": "[GET] \"/api/kv\": 422 ",
    "stack": "<pre><span class=\"stack internal\">at async $fetch2 (./node_modules/ofetch/dist/shared/ofetch.37386b05.mjs:268:15)</span>\n<span class=\"stack\">at async setup (./pages/index.vue:17:115)</span></pre>",
    "data": "{\"url\":\"/api/kv\",\"statusCode\":422,\"statusMessage\":\"\",\"message\":\"NuxtHub kv is not enabled in the remote project. Enable it in your `nuxt.config.ts`, deploy new version and try again.\\n Read more at https://hub.nuxt.com/docs/getting-started/remote-storage\",\"stack\":\"<pre><span class=\\\"stack\\\">Read more at https://hub.nuxt.com/docs/getting-started/remote-storage</span>\\n<span class=\\\"stack internal\\\">at createError (./node_modules/h3/dist/index.mjs:79:15)</span>\\n<span class=\\\"stack internal\\\">at requireNuxtHubFeature (./node_modules/@nuxthub/core/dist/runtime/server/utils/features.mjs:37:11)</span>\\n<span class=\\\"stack internal\\\">at hubKV (./node_modules/@nuxthub/core/dist/runtime/server/utils/kv.mjs:10:3)</span>\\n<span class=\\\"stack\\\">at Object.handler (./server/api/kv.get.ts:2:1)</span>\\n<span class=\\\"stack internal\\\">at Object.handler (./node_modules/h3/dist/index.mjs:1888:24)</span>\\n<span class=\\\"stack internal\\\">at Object.handler (./node_modules/h3/dist/index.mjs:2196:34)</span>\\n<span class=\\\"stack internal\\\">at ./node_modules/h3/dist/index.mjs:1962:31</span>\\n<span class=\\\"stack internal\\\">at process.processTicksAndRejections (node:internal/process/task_queues:95:5)</span>\\n<span class=\\\"stack internal\\\">at async Object.callAsync (./node_modules/unctx/dist/index.mjs:72:16)</span>\\n<span class=\\\"stack internal\\\">at async toNodeHandle (./node_modules/h3/dist/index.mjs:2249:7)</span></pre>\",\"data\":{\"description\":\"Remote storage not enabled\"}}"
}

As you can see, the whole error stringified inside data

  • Show a warning on startup

WDYT?
Screenshot 2024-04-12 at 11 31 23

@atinux atinux merged commit eb3bd50 into main Apr 12, 2024
3 of 5 checks passed
Aslemammad pushed a commit to Aslemammad/nuxt-core that referenced this pull request Jun 12, 2024
…loyment (nuxt-hub#68)

* fix(remote-storage): raise error if storage is not enabled in the deployement

* up

* up

* Update src/runtime/server/utils/features.ts

* fix: startup warnings and errors

* up

* chore: up

---------

Co-authored-by: Sébastien Chopin <seb@nuxt.com>
@atinux atinux deleted the fix/remote-storage-error branch August 19, 2024 13:11
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.

2 participants