Skip to content
Discord Get Started

Troubleshooting

Terminal
# Last 20 runs (default)
db9 functions history my-func --db myapp
# Last 50 runs
db9 functions history my-func --db myapp -n 50
# Specific run details
db9 functions history my-func <run_id> --db myapp
# JSON output
db9 functions history my-func --db myapp --json
FieldDescription
idUnique run ID
statussucceeded or failed
result_jsonReturn value (if succeeded)
error_codeError type (if failed)
error_messageError details (if failed)
trigger_typeinvoke, cron, or api
started_atExecution start time
finished_atExecution end time
attemptRetry attempt number
version_idWhich version was executed
Terminal
db9 functions logs my-func <run_id> --db myapp

Logs capture all console.log() and console.error() output from the function.

Error CodeCauseResolution
execution_errorFunction threw an exception or returned invalid resultCheck error_message and logs for the stack trace
timeoutFunction exceeded timeout_ms limitIncrease timeout or optimize code
entrypoint_not_foundhandler export not foundUse module.exports = { handler: ... }

SQL errors from ctx.db.query() propagate as exceptions:

ErrorCause
permission denied for table XThe authenticated role lacks privileges. Run GRANT as admin.
relation "X" does not existTable not found. Check the table name and schema.
syntax error at or near "..."Invalid SQL. Check your query string.
  1. Check the run status and error:

    Terminal
    db9 functions history my-func --db myapp -n 1 --json
  2. Check the logs:

    Terminal
    db9 functions logs my-func <run_id> --db myapp
  3. Common causes:

    • execution_error — unhandled exception. Check logs for the stack trace.
    • execution_timeout — increase with --timeout.
    • permission denied for table X — grant access: GRANT ALL ON TABLE X TO authenticated;

”Entrypoint handler is not a function”

Section titled “”Entrypoint handler is not a function””

Your code doesn’t export handler as a named property. The runtime expects:

JavaScript
// Correct
module.exports = { handler: async (input, ctx) => { ... } };
// Wrong — bare function declaration isn't exported
async function handler(input, ctx) { ... }
// Wrong — module.exports as function (not object with handler key)
module.exports = async function handler(input, ctx) { ... };

The runtime uses CommonJS, not ES modules. export default is a syntax error:

JavaScript
// Wrong — ES module syntax is not supported
export default async function handler(input, ctx) { ... }
// Correct — use CommonJS
module.exports = { handler: async (input, ctx) => { ... } };

“Unsupported runtime imports detected”

Section titled ““Unsupported runtime imports detected””

The CLI detected require() calls that would fail at runtime. This happens when you use:

  • import somePackage from "package-name" — external npm packages are not available
  • import { something } from "./other-file" — multi-file imports are not supported

Bundle your code with esbuild to resolve all imports at build time. See Bundling.

  • Ensure your TypeScript syntax is valid
  • Use import type { ... } (not import { ... }) for type imports
  • Do not use import or require for runtime dependencies

If fetch() throws EACCES: permission denied ... url not in allowlist, the target URL must be added to the network_allowlist via the REST API.

Functions run as the authenticated role. Tables created by admin need explicit grants:

SQL
GRANT ALL ON TABLE my_table TO authenticated;
GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO authenticated;
LimitationDetails
Single-file deploymentMulti-file imports are not supported. Bundle with esbuild for complex projects.
No runtime npm packagesrequire("axios") fails. Bundle dependencies at build time.
TypeScript is transpile-onlyNo type checking at deploy time. Types are stripped.
No persistent stateEach invocation is isolated. Use ctx.db or ctx.fs9 to persist data.
Network requires allowlistfetch() is blocked by default. Configure network_allowlist via REST API.
No local emulatorTest by deploying to your database. There is no local dev server.
No delete commandFunctions cannot be deleted via CLI. Contact support if needed.
Authenticated roleFunctions run as authenticated, not admin. Grant table access explicitly.
Bundle sizeLarge bundles may hit the proxy body-size limit (413 error). Keep under 5 MB.