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

ReferenceError: self is not defined #1074

Open
1 task done
BorisZubchenko opened this issue Feb 2, 2024 · 0 comments
Open
1 task done

ReferenceError: self is not defined #1074

BorisZubchenko opened this issue Feb 2, 2024 · 0 comments
Labels
bug Something isn't working triage New issues that needs consideration

Comments

@BorisZubchenko
Copy link

Bug report

Packages affected

  • nodebox

Description of the problem

I can't make the simplest example work with Next.js and Nodebox.

What were you doing when the problem occurred?

What steps can we take to reproduce the problem?

  1. Create a Next.js app.
  2. Install nodebox
  3. Go to page.tsx
  4. Replace the content with:
'use client'

import { Nodebox } from '@codesandbox/nodebox'
import { useEffect, useRef } from 'react'

export default function Home() {
  const iframeRef = useRef<HTMLIFrameElement>(null)

  useEffect(() => {
    const thisEffect = async () => {
      if (!iframeRef.current) {
        return
      }

      const emulator = new Nodebox({
        iframe: iframeRef.current,
      })

      await emulator.connect()
    }

    thisEffect()
  })

  return (
    <div>
      <iframe
        id="nodebox-runtime-iframe"
        ref={iframeRef}
      />
    </div>
  )
}
  1. Get the following error (server):
 X node_modules/@codesandbox/nodebox/build/index.mjs (64:0) @ ../../node_modules/.pnpm/cuid@2.1.8/node_modules/cuid/lib/fingerprint.browser.js
 X ReferenceError: self is not defined
    at __webpack_require__ (/home/projects/stackblitz-starters-nxgtxn/.next/server/webpack-runtime.js:33:42)
    at eval (./app/page.tsx:7:78)
    at (ssr)/./app/page.tsx (/home/projects/stackblitz-starters-nxgtxn/.next/server/app/page.js:151:1)
    at __webpack_require__ (/home/projects/stackblitz-starters-nxgtxn/.next/server/webpack-runtime.js:33:42)
null

Link to sandbox: link

Your Environment

Software Name/Version
nodebox version 0.1.9
Browser N/A
Operating System N/A
@BorisZubchenko BorisZubchenko added bug Something isn't working triage New issues that needs consideration labels Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage New issues that needs consideration
Projects
None yet
Development

No branches or pull requests

1 participant