intlify / intlify/srvmid

`useTranslation` errors when used inside a Nitro request hook

Open
#23 11 comments 4 reactions 0 assignees View on GitHub
good first issue H3 status: need more repro codes or info status: pull request welcome
Dominant language
TypeScript
Stars
13
Forks
2
Avg merge
4h 14m
Merged PRs (30d)
4

Description

### Describe the bug

When used inside a [Nitro](https://nitro.unjs.io) request hook, useTranslation (for server-side translation) errors:
![image](https://github.com/intlify/srvmid/assets/92037085/c4aad17f-8e5a-4d35-b51e-e3f27d25187b)

### Reproduction

nitroApp.hooks.hook("request", async (event) => { const t = await useTranslation(event) })

### System Info

```Shell
------------------------------
- Operating System: Linux
- Node Version: v21.1.0
- Nuxt Version: 3.11.2
- CLI Version: 3.12.0
- Nitro Version: 2.9.6
- Package Manager: yarn@4.0.0
- Builder: -
- User Config: nitro, i18n, devtools, runtimeConfig, experimental, vite
- Runtime Modules: @nuxtjs/i18n@8.3.1
- Build Modules: -
------------------------------
```

### Used Package Manager

n/a

### Additional context

The reproduction provided is extremely minimal as that's all that needs to be done in order to trigger the error. If necessary, I can provide a less minimal reproduction, please do let me know!

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