Skip to content

require doesn't work in some contexts, possibly due to bad function wrapper equivalence #302

Closed
wesgarland/python-launch-job
#1
@wesgarland

Description

@wesgarland

Issue type

Bug

How did you install PythonMonkey?

None

OS platform and distribution

No response

Python version (python --version)

No response

PythonMonkey version (pip show pythonmonkey)

No response

Bug Description

There are two demo programs in my python-job-launch github repo; ping.py and ping-post-init.py

The are nearly identical, the difference is

39c39,40
< dcp_client['init'](go)
---
> dcp_client['init']()
> go()
[~/git2/python-launch-job] dev-wes:wes# 

The first one works and the second one doesn't. The reason it doesn't work is

Traceback (most recent call last):
  File "/home/wes/git2/python-launch-job/./ping-post-init.py", line 39, in <module>
    dcp_client['init']()
  File "/home/wes/git2/python-launch-job/node_modules/dcp-client/index.py", line 110, in init
    asyncio.run(load_dcp_client(*args, **kwargs))
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/home/wes/git2/python-launch-job/node_modules/dcp-client/index.py", line 51, in load_dcp_client
    dcp_client_modules = pm.eval("""'use strict';(
pythonmonkey.SpiderMonkeyError: Error in file /home/wes/git/pythonmonkey/python/pminit/pythonmonkey/node_modules/ctx-module/ctx-module.js, on line 238, column 21:
Error: module not found -- require('undefined/fs-basic') from undefined

The undefined happens because require can't figure out the relative path of dcp-client during init(). And it can't find it because somehow it's a Python function wrapper instead of a JS function, so the properties don't work.

Note that this needs the last dcp-client branches on the various repos to work.

Standalone code to reproduce the issue

No response

Relevant log output or backtrace

No response

Additional info if applicable

No response

What branch of PythonMonkey were you developing on? (If applicable)

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions