Skip to content

Conversation

@zdql
Copy link
Contributor

@zdql zdql commented Oct 24, 2025

Echo Balance can act as a creditor for x402 resources. This PR will enable you to spend your echo balance on x402 resources.

@railway-app
Copy link

railway-app bot commented Oct 24, 2025

🚅 Deployed to the echo-pr-614 environment in echo

Service Status Web Updated (UTC)
echo ✅ Success (View Logs) Web Oct 24, 2025 at 3:56 pm

@vercel
Copy link
Contributor

vercel bot commented Oct 24, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
assistant-ui-template Ready Ready Preview Comment Oct 24, 2025 3:52pm
echo-control Ready Ready Preview Comment Oct 24, 2025 3:52pm
echo-next-boilerplate Ready Ready Preview Comment Oct 24, 2025 3:52pm
echo-next-image Ready Ready Preview Comment Oct 24, 2025 3:52pm
echo-next-sdk-example Ready Ready Preview Comment Oct 24, 2025 3:52pm
echo-video-template Ready Ready Preview Comment Oct 24, 2025 3:52pm
echo-vite-sdk-example Ready Ready Preview Comment Oct 24, 2025 3:52pm
next-chat-template Ready Ready Preview Comment Oct 24, 2025 3:52pm
react-boilerplate Ready Ready Preview Comment Oct 24, 2025 3:52pm
react-chat Ready Ready Preview Comment Oct 24, 2025 3:52pm
react-image Ready Ready Preview Comment Oct 24, 2025 3:52pm
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
component-registry Skipped Skipped Oct 24, 2025 3:52pm

Comment on lines +75 to +79
getGloriaNews({ feed_categories: 'base' }, ECHO_API_KEY);
postTrueCastRequest(
'Was donald trump the first president of the united states?',
ECHO_API_KEY
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
getGloriaNews({ feed_categories: 'base' }, ECHO_API_KEY);
postTrueCastRequest(
'Was donald trump the first president of the united states?',
ECHO_API_KEY
);
getGloriaNews({ feed_categories: 'base' }, ECHO_API_KEY).then(() => {
console.log('done');
}).catch((error) => {
console.error('Error making getGloriaNews request:', error);
});
postTrueCastRequest(
'Was donald trump the first president of the united states?',
ECHO_API_KEY
).then(() => {
console.log('done');
}).catch((error) => {
console.error('Error making postTrueCastRequest:', error);
});

The module-level code at the end of the file executes async functions without awaiting them, which will cause unhandled promise rejections if these functions fail and cannot be debugged properly.

View Details

Analysis

Unhandled promise rejections in echo-credit-client.ts module-level code

What fails: Module-level async function calls getGloriaNews() and postTrueCastRequest() at lines 75-79 in packages/app/server/src/clients/echo-credit-client.ts cause unhandled promise rejections when ECHO_API_KEY environment variable is missing

How to reproduce:

# Import module without ECHO_API_KEY set:
cd packages/app/server && pnpm exec tsx -e "import('./src/clients/echo-credit-client.ts')"

Result: Process crashes with "UNHANDLED PROMISE REJECTION DETECTED: Error: ECHO_API_KEY is required" - both functions throw but have no .catch() handlers

Expected: Errors should be caught and handled gracefully like all other client files in the same directory, which use .then().catch() patterns for module-level async calls

Comment on lines +16 to +42
export async function postTrueCastRequest(
prompt: string,
apiKey?: string
): Promise<string> {
const key = apiKey || ECHO_API_KEY;

if (!key) {
throw new Error('ECHO_API_KEY is required');
}

const trueCastBody: TrueCastRequest = { prompt };

const response = await fetch(
`${ECHO_ROUTER_BASE_URL}/x402?proxy=${encodeURIComponent(TRUECAST_URL)}`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${key}`,
},
body: JSON.stringify(trueCastBody),
}
);
console.log('response', response.status);
const data = await response.json();
console.log('data', data);
return data;
Copy link
Contributor

Choose a reason for hiding this comment

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

The postTrueCastRequest function is declared to return Promise<string> but actually returns the parsed JSON response object, not a string. The same issue exists in getGloriaNews on line 45.

View Details
📝 Patch Details
diff --git a/packages/app/server/src/clients/echo-credit-client.ts b/packages/app/server/src/clients/echo-credit-client.ts
index aeb674ae..c55a261e 100644
--- a/packages/app/server/src/clients/echo-credit-client.ts
+++ b/packages/app/server/src/clients/echo-credit-client.ts
@@ -16,7 +16,7 @@ interface GloriaNewsParams {
 export async function postTrueCastRequest(
   prompt: string,
   apiKey?: string
-): Promise<string> {
+): Promise<any> {
   const key = apiKey || ECHO_API_KEY;
 
   if (!key) {
@@ -45,7 +45,7 @@ export async function postTrueCastRequest(
 export async function getGloriaNews(
   params: GloriaNewsParams = { feed_categories: 'base' },
   apiKey?: string
-): Promise<string> {
+): Promise<any> {
   const key = apiKey || ECHO_API_KEY;
 
   if (!key) {

Analysis

Type mismatch in postTrueCastRequest() and getGloriaNews() return types

What fails: Functions postTrueCastRequest() and getGloriaNews() in packages/app/server/src/clients/echo-credit-client.ts declare return type Promise<string> but actually return Promise<any> (parsed JSON objects)

How to reproduce:

// Functions call response.json() which returns Promise<any>, not Promise<string>
const data = await response.json(); // Returns object, not string
return data; // Type mismatch: returning object where Promise<string> expected

Result: TypeScript type checker allows incorrect type assumptions. Calling code expecting strings would receive objects at runtime.

Expected: Return type should be Promise<any> to match actual behavior per TypeScript fetch documentation - response.json() returns Promise<any>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants