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

Fix: undefined window on asigna initializer #405

Conversation

martinsvinicius
Copy link
Contributor

Description

Describe the changes that where made in this pull request. When possible start with a user story - short, simple descriptions of a feature told from the perspective of the person who desires the new capability. Be sure to also include the following information:

  1. Motivation for change
  • Server-side Next.js builds a broken because any import from @stacks/connect package will call initializeAsignaProvider which tries to access the window object without checking if it's defined.
  1. What was changed
  • Added a condition to check if window exists before trying to initialize Asigna Provider
  • Added changeset file
  1. How does this impact application developers
  • Fixes the broken builds
  1. Link to relevant issues and documentation

Type of Change

  • New feature
  • Bug fix
  • API reference/documentation update
  • Other

Does this introduce a breaking change?

No.

Are documentation updates required?

No.

@janniks

Copy link

vercel bot commented Feb 4, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
connect ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 4, 2025 1:59am
connect-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 4, 2025 1:59am

@CLAassistant
Copy link

CLAassistant commented Feb 4, 2025

CLA assistant check
All committers have signed the CLA.

@martinsvinicius
Copy link
Contributor Author

I've signed the License Agreement. FYI @janniks

Copy link
Collaborator

@janniks janniks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this 🙏🏻

@janniks janniks merged commit ed9532a into hirosystems:main Feb 4, 2025
4 checks passed
@martinsvinicius martinsvinicius deleted the fix/undefined-window-on-asigna-initializer branch February 4, 2025 02:28
@github-actions github-actions bot mentioned this pull request Feb 4, 2025
@dev-araujo
Copy link

@martinsvinicius
Is this update already in the default lib via npm?
I reinstalled the lib in my next project and it still fails to build

Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
**ReferenceError: window is not defined**
    at 2096 (/home/dev-araujo/Documents/github/blockchain-projects/learnweb3/STACKS/account-history/.next/server/chunks/412.js:10:30909)
    at t (/home/dev-araujo/Documents/github/blockchain-projects/learnweb3/STACKS/account-history/.next/server/webpack-runtime.js:1:143)
    at 1629 (/home/dev-araujo/Documents/github/blockchain-projects/learnweb3/STACKS/account-history/.next/server/app/page.js:1:6809)
    at t (/home/dev-araujo/Documents/github/blockchain-projects/learnweb3/STACKS/account-history/.next/server/webpack-runtime.js:1:143)
    at 1508 (/home/dev-araujo/Documents/github/blockchain-projects/learnweb3/STACKS/account-history/.next/server/app/page.js:1:4184)
    at Object.t [as require] (/home/dev-araujo/Documents/github/blockchain-projects/learnweb3/STACKS/account-history/.next/server/webpack-runtime.js:1:143)
    at require (/home/dev-araujo/Documents/github/blockchain-projects/learnweb3/STACKS/account-history/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:131:7946)
    at u (/home/dev-araujo/Documents/github/blockchain-projects/learnweb3/STACKS/account-history/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:36:646)
    at F (/home/dev-araujo/Documents/github/blockchain-projects/learnweb3/STACKS/account-history/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:36:10477)
    at T (/home/dev-araujo/Documents/github/blockchain-projects/learnweb3/STACKS/account-history/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:36:8526)
Export encountered an error on /page: /, exiting the build.
 ⨯ Static worker exited with code: 1 and signal: null

@janniks
Copy link
Collaborator

janniks commented Feb 5, 2025

Now released on npm 📦

@dev-araujo
Copy link

Thanks @janniks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Next.js build fails on 22.6.1
4 participants