ReferenceError: window is not defined

Hi,

I have a simple Confluence forge application that has been available through Marketplace for over a year. There was a recent update where the sole change was manifest.yaml to includes some new JS script addresses. Nothing change on the React app or Node.js backend.

In the last couple of weeks I notice that my logs are overflowing with the following error

ReferenceError: window is not defined
    at getCallBridge (webpack://confluence-macro-custom-ui/node_modules/@forge/bridge/out/bridge.js:9:1)
    at Object.9332 (webpack://confluence-macro-custom-ui/node_modules/@forge/bridge/out/invoke/invoke.js:7:1)
    at __webpack_require__ (webpack://confluence-macro-custom-ui/webpack/bootstrap:19:1)
    at Object.8350 (webpack://confluence-macro-custom-ui/node_modules/@forge/bridge/out/invoke/index.js:4:22)
    at __webpack_require__ (webpack://confluence-macro-custom-ui/webpack/bootstrap:19:1)
    at Object.2321 (webpack://confluence-macro-custom-ui/node_modules/@forge/bridge/out/index.js:5:22)
    at __webpack_require__ (webpack://confluence-macro-custom-ui/webpack/bootstrap:19:1)
    at /var/task/index.cjs:35722:71
    at getDefinitions (webpack://confluence-macro-custom-ui/src/index.js:47:49)
    at Object.<anonymous> (webpack://confluence-macro-custom-ui/src/index.js:47:49)

Looking at other threads, like Forge bridge invoke, ReferenceError: window is not defined error the problem seems to be calling @forge/bridge from the backend, however as I mentioned above the code base has not changed

It appears non-fatal as the application is working fine from an end user perspective. Any thoughts would be gratefully received.

Thanks and regards,

Andrew

Hey @AndrewTyson - A random thought - is it possible that when you ran a deploy with the updated manifest.yml that you didn’t have a package-lock.json with pinned dependencies, and that one or more of your dependent JS libraries have been changed to a newer version?

Thanks @HeyJoe - it turns out that the problem was a import { events } from '@forge/bridge'; in my Node.js. Removing the import resolved the issue. That import statement was in the codebase since the app was first deployed, so I guess something changed with the runtime.

Cheers,

Andrew

Glad you figured it out!