fix: make computeVendorKey async for Server Actions compatibility#671
Closed
github-actions[bot] wants to merge 1 commit intofeat/provider-vendor-recluster-host-portfrom
Closed
Conversation
Next.js 16 with Turbopack requires all exported functions in "use server" files to be async. The computeVendorKey function was synchronous but exported from a Server Actions module, causing the build to fail. Changes: - Make computeVendorKey async and return Promise<string | null> - Update all call sites to await the function - Update tests to use async/await pattern Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the
Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CI Auto-Fix
Original PR: #670
Failed CI Run: PR Build Check
Problem
The Docker Build Test failed with:
Next.js 16 with Turbopack requires all exported functions in
"use server"files to be async. ThecomputeVendorKeyfunction was synchronous but exported from a Server Actions module.Fixes Applied
src/repository/provider-endpoints.tscomputeVendorKeyasync, returnPromise<string | null>src/repository/provider-endpoints.tsawaitto call sites (lines 262, 382)src/actions/providers.tsawaitto call site (line 3624)tests/unit/repository/provider-endpoints-vendor-key.test.tsVerification
The fix is minimal and safe:
awaitis straightforwardAuto-generated by Claude AI
Greptile Overview
Greptile Summary
This PR fixes a Next.js 16 Turbopack compilation error by making the
computeVendorKeyfunction async to comply with Server Actions requirements.Key Changes:
computeVendorKeyasync and changed return type fromstring | nulltoPromise<string | null>awaitto all 3 call sites in production code (lines 262, 382 inprovider-endpoints.tsand line 3624 inproviders.ts)Analysis:
The fix is minimal and correct. The function body remains completely unchanged - it still performs the same synchronous computation. Making it async simply wraps the return value in a resolved Promise, which is required by Next.js 16 when functions are exported from a
"use server"module. All calling functions were already async, so addingawaitwas straightforward with no cascade effects.Confidence Score: 5/5
Important Files Changed
computeVendorKeyasync and added await to 2 call sites for Server Actions compliancecomputeVendorKeycall inreclusterProviderVendorsSequence Diagram
sequenceDiagram participant CallerFunc as Calling Function participant VendorKey as computeVendorKey (now async) participant Normalize as Normalization Helpers Note over VendorKey: Changed to async for<br/>Next.js 16 Server Actions CallerFunc->>VendorKey: await computeVendorKey(params) alt Has websiteUrl VendorKey->>Normalize: normalizeWebsiteDomainFromUrl Normalize-->>VendorKey: returns domain name else No websiteUrl VendorKey->>Normalize: normalizeHostWithPort Normalize-->>VendorKey: returns address and port end VendorKey-->>CallerFunc: Promise resolves to result Note over VendorKey: Logic unchanged<br/>Signature updated only