intlify / intlify/srvmid

Occasional error with `useTranslation` on Vercel

Open
#25 2 comments 0 reactions 0 assignees View on GitHub
H3 status: review needed
Dominant language
TypeScript
Stars
13
Forks
2
Avg merge
4h 14m
Merged PRs (30d)
4

Description

### Describe the bug

Related to intlify/srvmid#23 because it's the same error, but not because `useTranslation` is called in `request` hook.

Deploy the reproduction to Vercel and put a ping on it.
I have got uptime kuma calling /api/webhook endpoint every minute. Works fine for about 2 hours and then suddenly
```
[nuxt] [request error] [unhandled] [500] middleware not initialized, please setup `onRequest` and `onAfterResponse` options of `createApp` with the middleware obtained with `defineI18nMiddleware`
```

Could be a nuxt/i18n issue.

Edit: no issue on Cloudflare, where I also deployed the same reproduction.

### Reproduction

https://github.com/DavidDeSloovere/nuxt-i18n-nitro-issue31

Deploy to Vercel. Call /api/webhook.

### System Info

Deployed on Vercel. With Node 22.x

### Used Package Manager

pnpm

### Additional context

The error can also be thrown just after deployment.
My guess would be that the order in which plugin/middleware/eventhandler get executed isn't correct.
So I would assume it has something to do with cold start and the order of the i18n middleware that is running AFTER the request is being handled.

Log of failed request:
"onRequest" comes AFTER "webhook entered"
![Image](https://github.com/user-attachments/assets/af10b3c6-c904-49db-8193-f00cff17d228)

Log of working request:

![Image](https://github.com/user-attachments/assets/51a61498-0557-403d-a3f7-8e9db5c0dba6)

### Validations

- [x] Follow our [Code of Conduct](https://github.com/intlify/.github/blob/main/CODE_OF_CONDUCT.md)
- [x] Read the [Contributing Guide](https://github.com/intlify/h3/blob/main/CONTRIBUTING.md).
- [x] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [x] Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
- [x] The provided reproduction is a [minimal reproducible](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.