edge-runtime: GOOGLE_SDK_NODE_LOGGING error on edge function

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

The function is throwing an error that was previously not there. It does not get to the Deno.serve portion of the code in the example below

To Reproduce

import 'jsr:@supabase/functions-js/edge-runtime.d.ts';
import { sheets } from 'npm:@googleapis/sheets';
import { JWT } from 'npm:google-auth-library';

// Create a new JWT client using the credentials
console.log('Creating Google JWT client');
const googleAuthJwt = new JWT({
  email: Deno.env.get('GOOGLE_SHEETS_API_CLIENT_EMAIL'),
  key: Deno.env.get('GOOGLE_SHEETS_API_PRIVATE_KEY'),
  scopes: ['https://www.googleapis.com/auth/spreadsheets'],
});

// Authorize and create a Google Sheets API instance
console.log('Connecting to Google Sheets API with JWT client');
const sheetsApi = sheets({ version: 'v4', auth: googleAuthJwt });

Deno.serve(async (req) => {
  return new Response('OK');
});

Expected behavior

A response is returned from the function

System information

  • OS: Windows & GH Action
  • Version of supabase-js: 2
  • Version of Node.js: 20.17.0

Additional context

Error message I’m getting

{
  "event_message": "event loop error: TypeError: Cannot read properties of undefined (reading 'GOOGLE_SDK_NODE_LOGGING')\n    at Object.log (file:///var/tmp/sb-compile-edge-runtime/node_modules/localhost/google-logging-utils/0.0.2/build/src/logging-utils.js:356:36)\n    at Object.<anonymous> (file:///var/tmp/sb-compile-edge-runtime/node_modules/localhost/gcp-metadata/6.1.1/build/src/index.js:52:20)\n    at Object.<anonymous> (file:///var/tmp/sb-compile-edge-runtime/node_modules/localhost/gcp-metadata/6.1.1/build/src/index.js:409:4)\n    at Module._compile (node:module:731:34)\n    at Module._extensions..js (node:module:745:10)\n    at Module.load (node:module:656:32)\n    at Module._load (node:module:524:12)\n    at Module.require (node:module:675:19)\n    at require (node:module:790:16)\n    at Object.<anonymous> (file:///var/tmp/sb-compile-edge-runtime/node_modules/localhost/google-auth-library/9.14.0/build/src/auth/googleauth.js:31:21)",
  "id": "01d2fcd5-340d-42b6-85a5-0c477ed3b84c",
  "metadata": [
    {
      "boot_time": null,
      "cpu_time_used": null,
      "deployment_id": "box..._..._68",
      "event_type": "UncaughtException",
      "execution_id": "f6c241a9-65d7-4c2a-907f-f497b36cb441",
      "function_id": "...",
      "level": "error",
      "memory_used": [],
      "project_ref": "...",
      "reason": null,
      "region": "us-west-1",
      "served_by": "supabase-edge-runtime-1.66.5 (compatible with Deno v1.45.2)",
      "timestamp": "2025-02-02T15:34:11.110Z",
      "version": "68"
    }
  ],
  "timestamp": 1738510454102522
}

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 3
  • Comments: 23 (11 by maintainers)

Most upvoted comments

After further checking, I’ve confirmed there’s a PR that solves this issue in the Deno repo. This issue is fixed directly upstream, so the edge runtime will also reflect the change.

https://github.com/denoland/deno/pull/27891

Typically in CI, edge-runtime is not used to run test code, but rather Deno, as you are doing.

If you want to fix errors in your test code, then yes, you should use 2.x.

...
          deno-version: v1.x

This upstream bug was fixed in Deno 2.1.10, and we cherry-picked the fix ourselves, so you may experience this issue if you using Deno v1.46.3.

Ok. That doesn’t work when I have supabase cli installed via scoop on Windows. So, I downloaded the package for windows amd64 from the packages and replaced the scoop supabase.exe file with the updated one. The file is located at %USERPROFILE%\scoop\apps\supabase\current for anyone else that needs to do the same

The stable CLI is released at regular intervals, so as you said, the edge runtime version is likely to remain the same for the time being. If you still want to use the latest version of edge-runtime, you can use the beta release channel by typing npm install supabase@beta.

@JetUni Sorry. We have just submitted this change to the internal infrastructure. (Even if it is merged in the edge runtime, it is not immediately reflected in prod)

I’ve also attempted to rule out this project by deploying my functions using an earlier version of the CLI, but I can’t get it to use an earlier version of the edge-runtime. I’ve also tried deleting all my functions and re-deploying with the older CLI. Is there some other way that I can downgrade the version for my project?

I did already check from the dependency side by specifying a version that was in my lock file and was known to be working. In the future, I’ll utilize the deno.json file now that I’m aware of it.

The only place this seems to be used in the Google code is here, which is why I rushed into thinking it was related to the process.env https://github.com/googleapis/gax-nodejs/blob/c7e069656f7fb13e4fe82e374dbd1af49dbfdb16/logging-utils/src/logging-utils.ts#L470

In my commit, I locked them to these versions:

npm:@googleapis/sheets@9.3.1
npm:google-auth-library@9.14.0
npm:googleapis-common@7.2.0

I was hasty and jumped to conclusions of what the bug was. After I tested my own original “steps to reproduce”, I found out I was wrong. So, I went back to the basics of what I understand and edited the description. Sorry if I created any confusion