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

Jupyter crashes with pyodide error 'NameError: name 'false' is not defined' when trying to use lite mode #272

Open
sok82 opened this issue Jul 25, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@sok82
Copy link
Contributor

sok82 commented Jul 25, 2024

Description

When I'm trying to use Jupyter component liteMode=true and pass python code for execution to Output component I got an error of pyodide with error message

Traceback (most recent call last):
  File "/lib/python311.zip/_pyodide/_base.py", line 573, in eval_code_async
    await CodeRunner(
  File "/lib/python311.zip/_pyodide/_base.py", line 395, in run_async
    await coroutine
  File "<exec>", line 6, in <module>
NameError: name 'false' is not defined

Reproduce

Simplified version of my code

function MyComponent({code, kernel} : {code:string, kernel}) {
const [executeTrigger, setExecuteTrigger] = useState(0);

return <Jupyter 
                  lite={true}
                  useRunningKernelIndex={-1}
                  startDefaultKernel={true}
                  terminals={false}             
              >
                 <Output                    
                        sourceId="src-1"
                        codePre=""
                        autoRun={false}
                        kernel={kernel}
                        code={code}
                        showEditor={false}
                        showControl={false}
                        executeTrigger={executeTrigger}      
              />

</Jupyter>
}

Steps to reproduce

  1. Initialization works fine
  2. I execute code by incrementing executeTrigger
  3. When I set code value to something like
job_satisfaction_rate_train = pd.read_csv('https://my.domain.com/datasets/dataset.csv')

execution also doesn't return any error

  1. But when I set code value
plt.hist(job_satisfaction_rate_train['job_satisfaction_rate'], bins=50);
plt.grid();

I got pyodide error NameError: name 'false' is not defined

  • Everything works fine when lite mode is false and remote server is used
  • plt package is imported earlier

Browser logs data

Existing JupyterLite ServiceWorkers unregistered
service-manager.ts:60 Registering new JupyterLite ServiceWorker http://localhost:3000/[object Object]
State.ts:167 Kernel Manager is Ready KernelManager
State.ts:202 Starting Kernel Name: python

then

script has an unsupported MIME type ('text/html').
pyodide.asm.js:9 Loading micropip, packaging
pyodide.asm.js:9 Loading micropip, packaging
pyodide.asm.js:9 Loaded micropip, packaging
pyodide.asm.js:9 Loaded micropip, packaging
kernel.js:40 Uncaught (in promise) PythonError: Traceback (most recent call last):
  File "/lib/python311.zip/_pyodide/_base.py", line 573, in eval_code_async
    await CodeRunner(
  File "/lib/python311.zip/_pyodide/_base.py", line 395, in run_async
    await coroutine
  File "<exec>", line 6, in <module>
NameError: name 'false' is not defined
@sok82 sok82 added the bug Something isn't working label Jul 25, 2024
@echarles
Copy link
Member

echarles commented Sep 9, 2024

I have tried this recently and was not able to reproduce. @sok82 Are you still facing the issue?

@sok82
Copy link
Contributor Author

sok82 commented Oct 15, 2024

Hey @echarles ,
returned back to this issue

It's still here and I guess the problem is in URL that is used to load serviceWorker.
In debug mode I see that workerUrl that is used to load is http://localhost:3000/[object%20Object]?enableCache=false

And in response to this URL serviceWorker could not be loaded here in service-manager.js here

 if (!registration && serviceWorker) {
            try {
                // eslint-disable-next-line no-console
                console.info('Registering new JupyterLite ServiceWorker', workerUrl);
                registration = await serviceWorker.register(workerUrl);
                // eslint-disable-next-line no-console
                console.info('JupyterLite ServiceWorker was sucessfully registered');
            } catch (err) {
                console.warn(err);
                console.warn(`JupyterLite ServiceWorker registration unexpectedly failed: ${err}`);
            }
        }

@doelgonzo
Copy link

Hey @echarles , returned back to this issue

It's still here and I guess the problem is in URL that is used to load serviceWorker. In debug mode I see that workerUrl that is used to load is http://localhost:3000/[object%20Object]?enableCache=false

And in response to this URL serviceWorker could not be loaded here in service-manager.js here

 if (!registration && serviceWorker) {
            try {
                // eslint-disable-next-line no-console
                console.info('Registering new JupyterLite ServiceWorker', workerUrl);
                registration = await serviceWorker.register(workerUrl);
                // eslint-disable-next-line no-console
                console.info('JupyterLite ServiceWorker was sucessfully registered');
            } catch (err) {
                console.warn(err);
                console.warn(`JupyterLite ServiceWorker registration unexpectedly failed: ${err}`);
            }
        }

I was getting this workerUrl until i started packaging this with yarn, not sure that is your issue, but I was consistently seeing the above until I made the switch from npm to yarn. Not sure why it matters, but it matters.

@echarles
Copy link
Member

Great. I let you close as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants