Skip to main content

FUNCTIONS_EXECUTE_FAIL

Encountering an error? Get help with AI tools

Error Cause​

Execute function failed, please check if function call parameters are correct, troubleshoot function logic, or query error information through Cloud Function Logs.

Common Scenarios​

HTTP Cloud Function Call Failure​

If you are using HTTP Cloud Functions, the FUNCTIONS_EXECUTE_FAIL error may be caused by:

1. Missing or Incorrect Port Configuration​

Issue: HTTP cloud functions must listen on port 9000 by default. If the port is not configured or set to a different value, the function will fail to execute.

Incorrect Examples:

// ❌ Wrong: No port specified
app.listen();

// ❌ Wrong: Using incorrect port
app.listen(3000);

Correct Approach:

// ✅ Correct: Listen on port 9000
const PORT = process.env.PORT || 9000;
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});

2. Incorrect Route Path Configuration​

Issue: When calling HTTP cloud functions, the path must match the routes defined in the function. Path mismatches will result in 404 or function execution failures.

Incorrect Example:

// Route defined in function
app.get('/api/users', (req, res) => {
res.json({ users: [] });
});

// ❌ Wrong call path (missing /api prefix)
// https://xxx.app.tcloudbase.com/function-name/users

Correct Approach:

// ✅ Correct call path (includes complete route)
// https://xxx.app.tcloudbase.com/function-name/api/users

// Or use root path route
app.get('/', (req, res) => {
res.json({ message: 'Hello' });
});
// Call: https://xxx.app.tcloudbase.com/function-name/

3. SSE/WebSocket Path Configuration Issues​

If using SSE or WebSocket features, ensure paths match correctly:

// SSE route example
app.get('/sse', (req, res) => {
const sse = context.sse?.();
// SSE handling logic
});
// Call: https://xxx.app.tcloudbase.com/function-name/sse

// WebSocket route example
app.get('/ws', (req, res) => {
const { ws } = context;
// WebSocket handling logic
});
// Call: wss://xxx.app.tcloudbase.com/function-name/ws

Troubleshooting Steps​

  1. Check function logs: Visit Cloud Function Logs to view detailed error information
  2. Verify port configuration: Ensure function code listens on port 9000
  3. Check route paths: Ensure the path in the call URL matches routes defined in the function
  4. Test function logic: Use console function testing to validate code logic
  5. Review network requests: Use browser developer tools or curl to inspect complete requests and responses