Skip to content

BrowserSync Client sporadically generates an Uncaught TypeError #2085

@thomaspatrickwelborn

Description

@thomaspatrickwelborn

Issue details

BrowserSync Client sporadically generates an Uncaught TypeError.

Error

browser-sync-client.js:1 Uncaught TypeError: Cannot read properties of undefined (reading 'socketConfig')
    at e.initSocket (browser-sync-client.js:1:26836)
    at browser-sync-client.js:1:180515
    at browser-sync-client.js:1:181484
    at browser-sync-client.js:1:181487

Effect

BrowserSync features ARE FUNCTIONAL regardless whether err generated or not.

Expectation

BrowserSync should not generate errors or innocuous errors should have suppressability.

Steps to reproduce/test case

  1. Create BrowserSync Instance
  2. Initialize BrowserSync Instance
  3. Open browser at ACCURATE_URL
  4. Load BrowserSync Client Script Source
  5. Refresh page or reload application multiple times at different intervals to generate error.

Reproduction Notes

Error sometimes appears, sometimes does not appear.

Browsersync, node, npm versions

  • Browsersync [v3.0.2]
  • Node [v22.4.0]
  • Npm [v10.8.2]

Affected platforms

  • linux

Browsersync use-case

  • API

BrowserSync API Init

const browserSyncServerOptions = {
  ui: false,
  open: false, 
  https: {
    key: 'ACCURATE_PATH_HERE.key,
    cert: 'ACCURATE_PATH_HERE.crt',
  },
  host: ACCURATE_DOMAIN,
  port: ACCURATE_PORT_NUMBER,
  proxy: {
    target: 'https://ACCURATE_DOMAIN:ACCURATE_PORT_NUMBER',
    ws: false,
  },
  files: [
    path.join(process.env.PWD, 'localhost/**/*'),
    path.join(process.env.PWD, 'static/dependencies/**/*'),
  ],
}
const browserSyncServer = browserSync.create()
browserSyncServer.init(browserSyncServerOptions)

BrowserSync Client Snippet

<script async id="__bs_script__" src="/dependencies/browser-sync-client.js"></script>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions