-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Summary
The JS client generated by @codama/renderers-js only includes program error messages when NODE_ENV !== 'production'. In production builds (e.g., Next.js), getErrorMessage() always returns the placeholder and the app shows the “npx @solana/errors decode …” hint instead of the program’s custom error message. Shipping the generated folder does not help because the guard is evaluated at build time.
Problem to solve
Steps to Reproduce
- Create an Anchor program with custom errors (e.g., code 6000, message “Factory paused.”).
- Run codama with @codama/renderers-js to generate the JS client.
- Use the generated getErrorMessage() (or similar helper) in a Next.js app to map custom errors.
- Run in dev mode, trigger custom error -> message appears.
- Build and run production, trigger the same error.
Actual Behavior
- In production, getErrorMessage(code) returns:
"Error message not available in production bundles." - The SolanaError message includes:
Solana error #<code>; Decode this error by running npx @solana/errors decode -- <code> ...
Expected Behavior
- There should be a supported way to include custom program error messages in production, or a documented recommended approach for accurate error decoding in production (client or server).
Generated Output (snippet)
The generated file uses a production guard:
let myProgramErrorMessages: Record<MyProgramError, string> | undefined;
if (process.env.NODE_ENV !== 'production') {
myProgramErrorMessages = { ... };
}
export function getMyProgramErrorMessage(code: MyProgramError): string {
if (process.env.NODE_ENV !== 'production') {
return myProgramErrorMessages![code];
}
return 'Error message not available in production bundles.';
}
### Proposed solution
May be error messages should be in production too.
### Alternatives considered
Environment
codama: 1.5.0
@codama/renderers-js: 1.5.5
@solana/kit: 5.4.0
Next.js: 16.0.10
Node: 20+
Questions / Request
Is there an official flag or supported option to always include error messages in production builds?
If not, what is the recommended pattern to handle custom program error decoding accurately in production?
Would you consider adding a renderer option (e.g., alwaysIncludeErrorMessages: true) or exporting a separate error map for production use?
### Additional context
_No response_Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request