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

async calls to getLanguage to support nextjs 15 #3188

Merged
merged 3 commits into from
Oct 29, 2024

Conversation

tconroy
Copy link
Contributor

@tconroy tconroy commented Oct 26, 2024

Relates to issue: opral/inlang-paraglide-js#245

Starting with latest RC of Next.js 15 (RC 2), the request APIs (including headers()) is async: nextjs.org/blog/next-15-rc2#async-request-apis-breaking-change.

This change breaks the getLanguage() function from @inlang/paraglide-next, (on the server):

opral/monorepo@a0aaf62/inlang/source-code/paraglide/paraglide-next/src/app/getLanguage.server.ts#L14

This PR updates the getLanguage() function (every function that uses it) to be async.

Note: I was not actually able to test this locally in-repo, as I don't have Doppler access and couldn't get the local env running fully. However I did run unit tests and build, both of which appeared to be passing.

Copy link

changeset-bot bot commented Oct 26, 2024

⚠️ No Changeset found

Latest commit: 9d9cd89

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

github-actions bot commented Oct 26, 2024

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@tconroy
Copy link
Contributor Author

tconroy commented Oct 26, 2024

I have read the CLA Document and I hereby sign the CLA

@tconroy
Copy link
Contributor Author

tconroy commented Oct 26, 2024

recheck

github-actions bot added a commit that referenced this pull request Oct 26, 2024
@asterikx
Copy link

asterikx commented Oct 26, 2024

@tconroy I think, it's best to mirror the new (async) function signatures in the client files (getLanguage.client.ts, initializeLanguage.client.ts, and createI18n.client.ts) to have an isomorphic API (same API on server & client). Otherwise, your changes look similar to mine overall. Thanks! 🙂

Copy link
Member

@samuelstroschein samuelstroschein left a comment

Choose a reason for hiding this comment

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

Good to merge and release with the minor request to change the client types to be sync.

@samuelstroschein
Copy link
Member

@tconroy @asterikx to get this PR merged and released, i would go ahead and change the client function types to be sync again #3188 (comment). if nobody objects, I'll do the change tmr and get this PR published :)

@tconroy tconroy force-pushed the tconroy/fix/nextjs-async-lang branch from 7cbf4cd to e4e1f08 Compare October 29, 2024 19:44
@tconroy
Copy link
Contributor Author

tconroy commented Oct 29, 2024

Sounds good. I've reverted that commit and have also merged in latest master to this branch, so should be all set.

@samuelstroschein samuelstroschein merged commit eb96c95 into opral:main Oct 29, 2024
2 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Oct 29, 2024
@samuelstroschein
Copy link
Member

Published as v0.7. Thanks @tconroy for the PR!

CleanShot 2024-10-29 at 17 27 01@2x

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants