Build Error: TypeError related to FinalizationRegistry in Edge Functions

Netlify Site Name: - hollywoodhalls

I’m encountering an issue while deploying my Angular application on Netlify. The build process completes successfully, but the deployment fails during the Edge Functions bundling step. The specific error is related to FinalizationRegistry.

Build Log

8:30:25 PM: build-image version: ecdc8b770f4a0193fd3f258c1bc6029e681813a4 (focal)
8:30:25 PM: buildbot version: 31384b9071289c6a22c9a280fe11b85737b6fd56
8:30:25 PM: Fetching cached dependencies
8:30:25 PM: Starting to download cache of 157.2MB
8:30:26 PM: Finished downloading cache in 1.6s
8:30:26 PM: Starting to extract cache
8:30:29 PM: Finished extracting cache in 2.297s
8:30:29 PM: Finished fetching cache in 3.957s
8:30:29 PM: Starting to prepare the repo for build
8:30:29 PM: Preparing Git Reference pull/55/head
8:30:31 PM: Starting to install dependencies
8:30:31 PM: Python version set to 3.8
8:30:32 PM: Attempting Ruby version 2.7.2, read from environment
8:30:32 PM: Using Ruby version 2.7.2
8:30:33 PM: Started restoring cached go cache
8:30:33 PM: Finished restoring cached go cache
8:30:34 PM: go version go1.19.13 linux/amd64
8:30:35 PM: Using PHP version 8.0
8:30:37 PM: Started restoring cached Node.js version
8:30:38 PM: Finished restoring cached Node.js version
8:30:38 PM: v18.20.4 is already installed.
8:30:38 PM: Now using node v18.20.4 (npm v10.7.0)
8:30:38 PM: Enabling Node.js Corepack
8:30:38 PM: Started restoring cached build plugins
8:30:38 PM: Finished restoring cached build plugins
8:30:38 PM: Started restoring cached corepack dependencies
8:30:38 PM: Finished restoring cached corepack dependencies
8:30:38 PM: No npm workspaces detected
8:30:38 PM: Started restoring cached node modules
8:30:38 PM: Finished restoring cached node modules
8:30:38 PM: Installing npm packages using npm version 10.7.0
8:30:39 PM: npm warn using --force Recommended protections disabled.
8:30:41 PM: added 37 packages, removed 113 packages, changed 11 packages, and audited 1091 packages in 3s
8:30:41 PM: 150 packages are looking for funding
8:30:41 PM:   run `npm fund` for details
8:30:41 PM: found 0 vulnerabilities
8:30:41 PM: npm notice
8:30:41 PM: npm notice New minor version of npm available! 10.7.0 -> 10.8.3
8:30:41 PM: npm notice Changelog: https://github.com/npm/cli/releases/tag/v10.8.3
8:30:41 PM: npm notice To update run: npm install -g npm@10.8.3
8:30:41 PM: npm notice
8:30:41 PM: npm packages installed
8:30:42 PM: Successfully installed dependencies
8:30:42 PM: Starting build script
8:30:43 PM: Detected 1 framework(s)
8:30:43 PM: "angular" at version "18.2.3"
8:30:43 PM: Section completed: initializing
8:30:45 PM: ​
8:30:45 PM: Netlify Build                                                 
8:30:45 PM: ────────────────────────────────────────────────────────────────
8:30:45 PM: ​
8:30:45 PM: ❯ Version
8:30:45 PM:   @netlify/build 29.54.0
8:30:45 PM: ​
8:30:45 PM: ❯ Flags
8:30:45 PM:   accountId: 5f672f83d18439031d28980e
8:30:45 PM:   baseRelDir: true
8:30:45 PM:   buildId: 66dddf230d8aab000973c1d8
8:30:45 PM:   deployId: 66dddf230d8aab000973c1da
8:30:45 PM: ​
8:30:45 PM: ❯ Current directory
8:30:45 PM:   /opt/build/repo
8:30:45 PM: ​
8:30:45 PM: ❯ Config file
8:30:45 PM:   No config file was defined: using default values.
8:30:45 PM: ​
8:30:45 PM: ❯ Context
8:30:45 PM:   deploy-preview
8:30:45 PM: ​
8:30:45 PM: ❯ Loading plugins
8:30:45 PM:    - @netlify/angular-runtime@2.1.0 from Netlify app
8:30:46 PM: ​
8:30:46 PM: Build command from Netlify app                                
8:30:46 PM: ────────────────────────────────────────────────────────────────
8:30:46 PM: ​
8:30:46 PM: $ CI= npm run build
8:30:46 PM: > unity@0.0.0 build
8:30:46 PM: > ng build
8:30:47 PM: ❯ Building...
8:31:06 PM: βœ” Building...
8:31:06 PM: Browser bundles
8:31:06 PM: Initial chunk files     | Names               |  Raw size | Estimated transfer size
8:31:06 PM: main-6SXYTM2P.js        | main                |   1.06 MB |               240.79 kB
8:31:06 PM: styles-R6UBXF4R.css     | styles              | 697.66 kB |                38.56 kB
8:31:06 PM: chunk-ETABVS4A.js       | -                   | 175.75 kB |                42.59 kB
8:31:06 PM: polyfills-MH5IBZ74.js   | polyfills           |  34.54 kB |                11.35 kB
8:31:06 PM:                         | Initial total       |   1.97 MB |               333.28 kB
8:31:06 PM: Lazy chunk files        | Names               |  Raw size | Estimated transfer size
8:31:06 PM: chunk-W6YATKXO.js       | index-esm           |  29 bytes |                29 bytes
8:31:06 PM: Server bundles
8:31:06 PM: Initial chunk files     | Names               |  Raw size
8:31:06 PM: chunk-ZGMJWUZG.mjs      | -                   |   1.11 MB | 
8:31:06 PM: server.mjs              | server              |   1.10 MB | 
8:31:06 PM: chunk-JNZ5CLHO.mjs      | -                   | 546.11 kB | 
8:31:06 PM: chunk-JA6YF543.mjs      | -                   | 542.39 kB | 
8:31:06 PM: polyfills.server.mjs    | polyfills.server    | 268.61 kB | 
8:31:06 PM: chunk-EXD34EPT.mjs      | -                   |   2.87 kB | 
8:31:06 PM: chunk-W6O7R4GF.mjs      | -                   |   2.30 kB | 
8:31:06 PM: render-utils.server.mjs | render-utils.server | 252 bytes | 
8:31:06 PM: main.server.mjs         | main.server         | 207 bytes | 
8:31:06 PM: Lazy chunk files        | Names               |  Raw size
8:31:06 PM: chunk-UX7DM3OC.mjs      | xhr2                |  12.08 kB | 
8:31:06 PM: chunk-YQIIFZC6.mjs      | index               | 121 bytes | 
8:31:06 PM: Application bundle generation complete. [18.871 seconds]
8:31:06 PM: Output location: /opt/build/repo/dist/Unity
8:31:06 PM: ​
8:31:06 PM: (build.command completed in 19.7s)
8:31:06 PM: Writing Angular SSR Edge Function ...
8:31:06 PM: ​
8:31:06 PM: Edge Functions bundling                                       
8:31:06 PM: ────────────────────────────────────────────────────────────────
8:31:06 PM: ​
8:31:06 PM: Packaging Edge Functions from .netlify/edge-functions directory:
8:31:06 PM:  - angular-ssr
8:31:13 PM: TypeError: Cannot read properties of undefined (reading 'FinalizationRegistry')
8:31:13 PM:     at file:///opt/build/repo/dist/Unity/server/chunk-JA6YF543.mjs:2:31224
8:31:13 PM:     at file:///opt/build/repo/dist/Unity/server/chunk-EXD34EPT.mjs:2:1078
8:31:13 PM:     at file:///opt/build/repo/dist/Unity/server/chunk-JA6YF543.mjs:39:10316
8:31:13 PM:     at file:///opt/build/repo/dist/Unity/server/chunk-EXD34EPT.mjs:2:1078
8:31:13 PM:     at file:///opt/build/repo/dist/Unity/server/chunk-JA6YF543.mjs:45:4459
8:31:13 PM:     at file:///opt/build/repo/dist/Unity/server/chunk-EXD34EPT.mjs:2:1078
8:31:13 PM:     at file:///opt/build/repo/dist/Unity/server/chunk-JA6YF543.mjs:51:45
8:31:13 PM: ​
8:31:13 PM: Bundling of edge function failed                              
8:31:13 PM: ────────────────────────────────────────────────────────────────
8:31:13 PM: ​
8:31:13 PM:   Error message
8:31:13 PM:   Could not load edge function at '/opt/build/repo/.netlify/edge-functions/angular-ssr/angular-ssr.mjs'. More on the Edge Functions API at https://ntl.fyi/edge-api.
8:31:13 PM: ​
8:31:13 PM:   Error location
8:31:13 PM:   While bundling edge function
8:31:13 PM: ​
8:31:13 PM:   Resolved config
8:31:13 PM:   build:
8:31:13 PM:     command: CI= npm run build
8:31:13 PM:     commandOrigin: ui
8:31:13 PM:     environment:
8:31:13 PM:       - CI
8:31:13 PM:       - NPM_FLAGS
8:31:13 PM:       - REVIEW_ID
8:31:13 PM:     publish: /opt/build/repo/dist/Unity/browser
8:31:13 PM:     publishOrigin: ui
8:31:13 PM:   plugins:
8:31:13 PM:     - inputs: {}
8:31:13 PM:       origin: ui
8:31:13 PM:       package: '@netlify/angular-runtime'
8:31:13 PM:   redirects:
8:31:14 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
8:31:14 PM:     - from: /*
      status: 200
      to: /index.html
8:31:14 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
8:31:14 PM: Failing build: Failed to build site
8:31:14 PM: Finished processing build request in 49.595s

angular.json

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "Unity": {
      "projectType": "application",
      "schematics": {
        "@schematics/angular:component": {
          "style": "scss"
        },
        "@schematics/angular:application": {
          "strict": true
        }
      },
      "root": "",
      "sourceRoot": "src",
      "prefix": "app",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:application",
          "options": {
            "outputPath": "dist/Unity",
            "index": "src/index.html",
            "polyfills": [
              "src/polyfills.ts"
            ],
            "tsConfig": "tsconfig.app.json",
            "inlineStyleLanguage": "scss",
            "allowedCommonJsDependencies": [
              "rxjs-compat",
              "lodash",
              "moment",
              "undici",
              "@grpc/grpc-js",
              "@grpc/proto-loader"
            ],
            "assets": [
              "src/favicon.ico",
              "src/assets",
              "src/_redirects",
              "src/sw.js"
            ],
            "styles": [
              "src/styles.scss",
              "node_modules/bulma/css/bulma.css",
              "node_modules/ngx-toastr/toastr.css"
            ],
            "scripts": [],
            "browser": "src/main.ts",
            "server": "src/main.server.ts",
            "prerender": false,
            "ssr": {
              "entry": "server.ts"
            }
          },
          "configurations": {
            "production": {
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "2.5mb",
                  "maximumError": "2.5mb"
                },
                {
                  "type": "anyComponentStyle",
                  "maximumWarning": "6kb",
                  "maximumError": "10kb"
                }
              ],
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ],
              "outputHashing": "all"
            },
            "development": {
              "optimization": false,
              "extractLicenses": false,
              "sourceMap": true,
              "namedChunks": true
            }
          },
          "defaultConfiguration": "production"
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "configurations": {
            "production": {
              "buildTarget": "Unity:build:production"
            },
            "development": {
              "buildTarget": "Unity:build:development"
            }
          },
          "defaultConfiguration": "development"
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "buildTarget": "Unity:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "src/test.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "tsconfig.spec.json",
            "karmaConfig": "karma.conf.js",
            "inlineStyleLanguage": "scss",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/styles.scss"
            ],
            "scripts": []
          }
        }
      }
    }
  }
}
1 Like

hi, sorry we missed this. Are you still experiencing your build issues?

I have the same issue now

Please share a reproduction if you have one.

Just passing command netlify deploy --build --prod and all breaks on Edge Functions bundling/
Here is the code:

Writing Angular SSR Edge Function
Writing Angular SSR Edge Function

(@netlify/angular-runtime onBuild completed in 11ms)

Functions bundling
The Netlify Functions setting targets a non-existing directory: netlify\functions

(Functions bundling completed in 3ms)

Edge Functions bundling

Packaging Edge Functions from .netlify\edge-functions directory:

  • angular-ssr
    TypeError: Cannot read properties of undefined (reading β€˜FinalizationRegistry’)
    at file:///C:/Users/John/Desktop/pledik-handmade/dist/pledik-handmade/server/chunk-ZGQMVWZX.mjs:2:31422
    at file:///C:/Users/John/Desktop/pledik-handmade/dist/pledik-handmade/server/chunk-WUI6SWGE.mjs:2:1064
    at file:///C:/Users/John/Desktop/pledik-handmade/dist/pledik-handmade/server/chunk-ZGQMVWZX.mjs:39:10358
    at file:///C:/Users/John/Desktop/pledik-handmade/dist/pledik-handmade/server/chunk-WUI6SWGE.mjs:2:1064
    at file:///C:/Users/John/Desktop/pledik-handmade/dist/pledik-handmade/server/chunk-ZGQMVWZX.mjs:45:4463
    at file:///C:/Users/John/Desktop/pledik-handmade/dist/pledik-handmade/server/chunk-WUI6SWGE.mjs:2:1064
    at file:///C:/Users/John/Desktop/pledik-handmade/dist/pledik-handmade/server/chunk-ZGQMVWZX.mjs:66:1695

Could you provide a repo where this happens?

It`s private.I can add you as a member if is possible for you

I can show you logic,pieces of code.Just tell what to show

When could you help me?How long should I wait for?

Feel free to add hrishikesh-k on GitHub to your repo. I can check it when I get a chance.

I’ve just added you.Check it please.Hope you will have the time to help.
Thanks!

I’ve narrowed down the issue and filed it for the devs to take a look at. However, I don’t know if/when this will be fixed. Will keep you posted.

I’m waiting for that.
Thanks a lot!

Hello!
Do you have any news?

You should be able to fix this by adding the following to the top (even before import statements) of src/main.server.ts:

if (typeof global === undefined) {
  globalThis.global = globalThis
}

I removed totaly firebase and did as you said.

Edge fucntions now crashes with such error:
Nov 6, 11:43:15 PM: 01JC1PX1 error [Angular SSR] ERROR TypeError: Cannot read properties of undefined (reading β€˜get’)
at Jt (file:///root/dist/pledik-handmade/server/chunk-3COH3FHG.mjs:29:2575)
at file:///root/dist/pledik-handmade/server/chunk-3COH3FHG.mjs:29:2820

I fixed that error.It was because of Swiper config,it should be located at the AfterNextRender method

Hi!

I encountered a bug and I don’t know why it’s happening. Most of the links to the pages work well when I share the link in Telegram, for example. But there are a few pages with very strange behavior.

If I use the full URL, the metadata won’t show. For example: https://pledik-handmade.netlify.app – the metadata won’t show in Telegram. Pledik Handmade - Π“ΠΎΠ»ΠΎΠ²Π½Π° сторінка (’ …pledik-handmade.netlify.app?asd’) – adding a ? and random letters will trigger the metadata to show.

Thanks for your help!

That’s likely a Telegram issue. They might have cached the data the first time they tried loading it, but couldn’t load it.You’d have to contact them to purge their cache.

I am also getting this error on an Angular 18 app with SSR. The error seems to be related to firebase.

The build works if I only use provideFirebaseApp(() => initializeApp(firebaseConfig)).

But once I include any other firebase provider such as provideAuth(() => getAuth()) this error is shown in the build:

TypeError: Cannot read properties of undefined (reading 'FinalizationRegistry')