MicrosoftEdge / MicrosoftEdge/WebView2Feedback

[Problem]: `Uncaught SyntaxError: Identifier 'gc' has already been declared` with Bundled Code in WebView2

Open
#5,306 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
PowerShell
Stars
526
Forks
67
PR merge metrics
No merged PRs in 30d

Description

What happened?

We are encountering a Uncaught SyntaxError: Identifier 'gc' has already been declared error when running our web application within a WebView2 environment. This error specifically points to a const variable named gc.

Our application's JavaScript code undergoes a bundling and minification process, which outputs a const gc variable as part of its optimized code. This bundled code functions correctly without any SyntaxError when directly opened and executed in the Microsoft Edge browser (which WebView2 is based on).

This suggests that the gc identifier is being declared elsewhere within the WebView2 runtime environment, leading to a conflict with our application's const gc declaration. It appears there might be an internal const gc variable or function being injected or used by the WebView2 runtime, causing the identifier collision.

Importance

Blocking. My app's basic functions are not working due to this issue.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

138.0.3351.77

SDK Version

1.0.2903.40

Framework

WinUI3/WinAppSDK

Operating System

Windows 11

OS Version

26100.4484

Repro steps
Steps to Reproduce
  1. Bundle and minify a JavaScript application that declares a const gc variable (or has a minified output that results in such a declaration).
  2. Load this application within a WebView2 control.
  3. Observe the Uncaught SyntaxError: Identifier 'gc' has already been declared error in the WebView2 console.
Expected Behavior

The application's bundled JavaScript should execute without SyntaxError due to identifier conflicts with internal WebView2 runtime variables, especially when the same code runs successfully in the standalone Edge browser.

Actual Behavior

The WebView2 environment throws an Uncaught SyntaxError: Identifier 'gc' has already been declared, preventing the application from loading correctly.

Repros in Edge Browser

No, issue does not reproduce in the corresponding Edge version

Regression

No, this never worked

Last working version (if regression)

No response

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the bundled and minified JavaScript with a const gc declaration in a WebView2 control using Runtime 138.0.3351.77 and SDK 1.0.2903.40, then compare it with the corresponding Edge version. Done means the application loads without the identifier SyntaxError in the WinUI3/WinAppSDK environment.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.