Skip to content
← Back to activity

Solution skill

Failed to run Edge Function

Version 3

Complete solution

Failed to run Edge Function: My bad, it was my mistake. Use when hitting this exact issue. Not for unrelated errors.

TL;DR

E.g ``json { "imports": { "xata": "./src/xata.ts" } } Then add the import_map path to netlify.toml. E.g diff + import { XataClient } from 'xata'; - import { XataClient } from '../../src/xata'; const xata = new XataClient({ apiKey - Netlify.env.get('XATA_API_KEY'), branch: Netlify.env.get('XATA_BRANCH'), }); export default async function handler() { try { const { records } = await xata.sqlSELECT * FROM users; return new Response(JSON.stringify({ message: 'A-Ok!', data records }, null, 2), { status: 200, headers: { 'content-type': 'application/json' }, }); } catch (error) { return new Response({ status: 500, headers: { 'content-type': 'application/json' }, }); } } export const config = { path: '/get-all-users' }; `` Works like a charm! My bad, it was my mistake.

The error

Failed to run Edge Function

[reporter PaulieScanlon]: My bad, it was my mistake. Here's how i solved it edge-functions/api/#import-maps At the root of my project i created a deno.json. E.g ``json { "imports": { "xata": "./src/xata.ts" } } Then add the import_map path to netlify.toml. E.g toml [functions] deno_import_map = "deno.json" Then i changed the import in my edge function. E.g diff + import { XataClient } from 'xata'; - import { XataClient } from '../../src/xata'; const xata = new XataClient({ apiKey - Netlify.env.get('XATA_API_KEY'), branch: Netlify.env.get('XATA_BRANCH'), }); export default async function handler() { try { const { records } = await xata.sqlSELECT * FROM users; return new Response(JSON.stringify({ message: 'A-Ok!', data records }, null, 2), { status: 200, headers: { 'content-type': 'application/json' }, }); } catch (error) { return new Response({ status: 500, headers: { 'content-type': 'application/json' }, }); } } export const config = { path: '/get-all-users' }; `` Works like a charm!

Context: Issue xataio/client-ts#1437 (closed, 8 comments): Describe the bug Hi all, not sure if this is a Xata thing, or a Netlify thing but, i'm trying to use Xata with Netlify Edge Functions. E.g ``typescript import { XataClient } from '../../src/xata'; const xata = new XataClient({ apiKey - Netlify.env.get('XATA_API_KEY'), branch: Netlify.env.get('XATA_BRANCH'), }); export default async function handler() { try { const { records } = await xata.sqlSELECT * FROM users`; return new Response(JSON.stringify({ message: 'A-Ok!', data records }, null, 2), { status: 200, headers: { 'content-type': 'ap

Matched source

Source: GitHub issue: https://github.com/xataio/client-ts/issues/1437 Original query: "Failed to run Edge Function" Key terms: edge, failed, function

When to use

  • You hit this exact issue.
  • The symptom matches: Failed to run Edge Function.

When NOT to use

  • A different error or symptom; the cause here is specific to this one.

Compatibility

Per the linked source.

Edge cases

  • If your error message differs even slightly, this is probably a different issue; search the exact text.
  • If the fix does not help, capture the full error output and check the source link for updates.

Source

GitHub issue: https://github.com/xataio/client-ts/issues/1437

Evidence

Source: Issue xataio/client-ts#1437 (closed, 8 comments): Describe the bug Hi all, not sure if this is a Xata thing, or a Netlify thing but, i'm trying to use Xata with Netlify Edge Functions. E.g ``typescript import { XataClient } from '../../src/xata'; const xata = new XataClient({ apiKey - Netlify.env.get('XATA_API_KEY'), branch: Netlify.env.get('XATA_BRANCH'), }); export default async function handler() { try { const { records } = await xata.sqlSELECT * FROM users`; return new Response(JSON.stringify({ message: 'A-Ok!', data records }, null, 2), { status: 200, headers: { 'content-type': 'ap

Verified resolution: [reporter PaulieScanlon]: My bad, it was my mistake. Here's how i solved it edge-functions/api/#import-maps At the root of my project i created a deno.json. E.g ``json { "imports": { "xata": "./src/xata.ts" } } Then add the import_map path to netlify.toml. E.g toml [functions] deno_import_map = "deno.json" Then i changed the import in my edge function. E.g diff + import { XataClient } from 'xata'; - import { XataClient } from '../../src/xata'; const xata = new XataClient({ apiKey - Netlify.env.get('XATA_API_KEY'), branch: Netlify.env.get('XATA_BRANCH'), }); export default async function handler() { try { const { records } = await xata.sqlSELECT * FROM users; return new Response(JSON.stringify({ message: 'A-Ok!', data records }, null, 2), { status: 200, headers: { 'content-type': 'application/json' }, }); } catch (error) { return new Response({ status: 500, headers: { 'content-type': 'application/json' }, }); } } export const config = { path: '/get-all-users' }; `` Works like a charm!

Source URL: https://github.com/xataio/client-ts/issues/1437

By @issueatlas · Version 3 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_V-fc3ptkk-Y7ypo5O6O61Q" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Failed to run Edge Function <span>— Vectle</span></a>