Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught SyntaxError in Firefox: Missing { Before Function Body (chunk-ACB7EEIH.js) #8368

Open
Christopher-C-Robinson opened this issue Jan 29, 2025 · 3 comments · May be fixed by #8369
Open
Labels
STATE: Issue accepted An issue has been reproduced. TYPE: bug The described behavior is considered as wrong (bug).

Comments

@Christopher-C-Robinson
Copy link

What is your Scenario?

Description:
We are encountering an issue in Firefox that does not appear in Chrome or Edge. When running our application, we receive the following error in the console:

Uncaught SyntaxError: missing { before function body
chunk-ACB7EEIH.js:2:27106

This error is preventing the application from functioning correctly in Firefox. The issue seems to be related to TestCafe's Hammerhead processing script, as shown in the following snippet:

/*hammerhead|script|start*/if (typeof globalThis.window !== 'undefined' && globalThis.window){
    globalThis.window['hammerhead|process-dom-method'] && globalThis.window['hammerhead|process-dom-method']();
    if (globalThis.window.__get$ && typeof __get$ === 'undefined')
    var __get$Loc = globalThis.window.__get$Loc,
    __set$Loc = globalThis.window.__set$Loc,
    __set$ = globalThis.window.__set$,
    __get$ = globalThis.window.__get$,
    __call$ = globalThis.window.__call$,
    __get$Eval = globalThis.window.__get$Eval,
    __proc$Script = globalThis.window.__proc$Script,
    __proc$Html = globalThis.window.__proc$Html,
    __get$PostMessage = globalThis.window.__get$PostMessage,
    __get$ProxyUrl = globalThis.window.__get$ProxyUrl,
    __rest$Array = globalThis.window.__rest$Array,
    __rest$Object = globalThis.window.__rest$Object,
    __arrayFrom$ = globalThis.window.__arrayFrom$;
} else {
    if (typeof __get$ === 'undefined')
    var __get$Loc = function(l){return l},
    __set$Loc = function(l,v){return l = v},
    __set$ = function(o,p,v){return o[p] = v},
    __get$ = function(o,p){return o[p]},
    __call$ = function(o,p,a){return o[p].apply(o,a)},
    __get$Eval = function(e){return e},
    __proc$Script = function(s){return s},
    __proc$Html = function(h){return h},
    __get$PostMessage = function(w,p){return arguments.length===1?w.postMessage:p},
    __get$ProxyUrl = function(u,d){return u},
    __rest$Array = function(a,i){return Array.prototype.slice.call(a, i)},
    __rest$Object = function(o,p){var k=Object.keys(o),n={};for(var i=0;i<k.length;++i)if(p.indexOf(k[i])<0)n[k[i]]=o[k[i]];return n},
    __arrayFrom$ = function(r){if(!r)return r;return!Array.isArray(r)&&"function"==typeof r[Symbol.iterator]?Array.from(r):r};
}

Steps to Reproduce:

  1. Run the application in Firefox.
  2. Observe the console error Uncaught SyntaxError: missing { before function body.
  3. Try running the same application in Chrome or Edge; the error does not appear.

Expected Behavior:
The application should function without syntax errors in Firefox, as it does in Chrome and Edge.

Actual Behavior:
Firefox throws a SyntaxError, preventing proper execution.

Environment:

  • Browser: Firefox (latest version)
  • Other Browsers Tested: Chrome (✅ No Issue), Edge (✅ No Issue)
  • TestCafe Version: [Provide your TestCafe version]
  • DevExpress Version: [Provide your DevExpress version]
  • Operating System: [Specify OS and version]

Additional Context:

  • This issue only occurs in Firefox, which suggests a browser-specific parsing issue.
  • It may be related to how TestCafe’s Hammerhead modifies scripts.

Would appreciate any insights or fixes for this issue. Thanks!

What is the Current behavior?

Firefox throws a SyntaxError, preventing proper execution.

What is the Expected behavior?

The application should function without syntax errors in Firefox, as it does in Chrome and Edge.

What is the public URL of the test page? (attach your complete example)

https://formspro.omnibyte.com/automation/nightly

What is your TestCafe test code?

test('Test Case: ##### - NEW', async t => {
    await t.navigateTo('https://formspro.omnibyte.com/automation/nightly');
});

### Your complete configuration file

{
"browsers": ["chrome:headless:emulation:width=1920;height=1080 --start-fullscreen;"],
"reporter": [
{
"name": "spec"
},
{
"name": "nunit3",
"output": "results/reports/report.xml"
}
],
"screenshots": {
"takeOnFails": true,
"path": "results/",
"pathPattern": "${TIME}/${TEST_INDEX}/${FILE_INDEX}.png"
},
"disablePageCaching": true,
"stopOnFirstFail": false,
"skipJsErrors": true,
"skipUncaughtErrors": true,
"selectorTimeout": 5000,
"assertionTimeout": 5000,
"pageLoadTimeout": 120000,
"speed": 1,
"cache": false
}


Note, I’m using [testcafe test runner](https://marketplace.visualstudio.com/items?itemName=romanresh.testcafe-test-runner) extension to run in Firefox


### Your complete test report

<?xml version="1.0" encoding="UTF-8" ?>
<test-run id="2" name="TestCafe Tests" start-time="2025-01-29T22:17:06.342Z" end-time="2025-01-29T22:17:08.375Z">
    <test-suite type="Assembly" name="Visual Settings" start-time="2025-01-29T22:17:06.344Z" end-time="2025-01-29T22:17:08.369Z">
        <test-case name="Test Case: ##### - NEW" fullname="Visual Settings - Test Case: ##### - NEW" result="Passed" duration="2.016">
        </test-case>
    </test-suite>
</test-run>

### Screenshots

![Image](https://github.com/user-attachments/assets/ba3d6aee-6f10-4351-901a-7c0b0fe2e1cb)

![Image](https://github.com/user-attachments/assets/d9ceadc0-140f-4757-8c61-db7527315cff)

### Steps to Reproduce

1. Run the application in Firefox.
2. Observe the console error `Uncaught SyntaxError: missing { before function body`.
3. Try running the same application in Chrome or Edge; the error does not appear.


### TestCafe version

3.7.1

### Node.js version

v20.17.0

### Command-line arguments

/usr/bin/env 'NODE_OPTIONS= --require "c:/Users/crobinson/AppData/Local/Programs/Microsoft VS Code/resources/app/extensions/ms-vscode.js-debug/src/bootloader.js"  --inspect-publish-uid=http' 'VSCODE_INSPECTOR_OPTIONS=:::{"inspectorIpc":"\\\\.\\pipe\\node-cdp.41644-11d630d7-105.sock","deferredMode":false,"waitForDebugger":"","execPath":"C:\\Program Files\\nodejs\\node.exe","onlyEntrypoint":false,"autoAttachMode":"always","fileCallback":"C:\\Users\\CROBIN~1\\AppData\\Local\\Temp\\node-debug-callback-a404d6afea03970e"}' C:\\Program\ Files\\nodejs\\node.exe --no-deprecation .\\node_modules\\testcafe\\lib\\cli\\index.js firefox c:\\Code\\FP\\Test-Automation\\FormsPro\\configuration\\visual-settings.ts -L --test Test\ Case:\ \#\#\#\#\#\ -\ NEW

### Browser name(s) and version(s)

 - Firefox 134.0

### Platform(s) and version(s)

Windows 11

### Other

_No response_
@Christopher-C-Robinson Christopher-C-Robinson added the TYPE: bug The described behavior is considered as wrong (bug). label Jan 29, 2025
@testcafe-need-response-bot testcafe-need-response-bot bot added the STATE: Need response An issue that requires a response or attention from the team. label Jan 29, 2025
@Bayheck
Copy link
Collaborator

Bayheck commented Jan 31, 2025

Hello,

I did not manage to reproduce the issue with your configuration as it has a flag skipJsErrors set to true.

However, I did get the error when skipJsErrors was set to false.

Please clarify whether you use skipJsErrors in your test runs.

@Bayheck Bayheck added STATE: Need clarification An issue lacks information for further research. and removed STATE: Need response An issue that requires a response or attention from the team. labels Jan 31, 2025
@Christopher-C-Robinson
Copy link
Author

Hi, I have skipJsErrors and skipUncaughtErrors set to true in the .testcaferc.json file.

@testcafe-need-response-bot testcafe-need-response-bot bot added the STATE: Need response An issue that requires a response or attention from the team. label Jan 31, 2025
@github-actions github-actions bot removed the STATE: Need clarification An issue lacks information for further research. label Jan 31, 2025
@Bayheck Bayheck added STATE: Issue accepted An issue has been reproduced. and removed STATE: Need response An issue that requires a response or attention from the team. labels Feb 4, 2025
Copy link

github-actions bot commented Feb 4, 2025

We appreciate you taking the time to share information about this issue. We reproduced the bug and added this ticket to our internal task queue. We'll update this thread once we have news.

@Bayheck Bayheck linked a pull request Feb 6, 2025 that will close this issue
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
STATE: Issue accepted An issue has been reproduced. TYPE: bug The described behavior is considered as wrong (bug).
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants