Distributive-Network / PythonMonkey

A Mozilla SpiderMonkey JavaScript engine embedded into the Python VM, using the Python engine to provide the JS host environment.
https://pythonmonkey.io
Other
854 stars 40 forks source link

Uncaught Error: Assertion failure AND Uncaught undefined DCPError: no transports defined #423

Closed philippedistributive closed 2 months ago

philippedistributive commented 2 months ago

Bug Description

With this code:

#!/usr/bin/env python3
import pythonmonkey as pm
dcp_client = pm.require('dcp-client')

# define the data your workfunction will operate on
lst1 = []
lst2 = []

arr_size = 2500
#arr_size = 5000
#arr_size = arr_size / 2 + arr_size / 4 + arr_size / 8 + arr_size / 16
arr_size = int(arr_size)
print(arr_size)

for i in range(arr_size):
    lst2.append([])
    for j in range(arr_size):
        lst2[i].append(i + j + (j + 0.1) / (i + j + 0.123456))
    lst1.append(i * i)

args2 = [lst1, lst2]

data = [1, 2, 3, 4, 5]

# function which will execute on each datum in the dataset remotely on dcp workers
work_function = """
function myEpicWorkFn(datum, arg1, arg2)
{
    progress();
    return arg1.length + arg2.length; + datum
}
"""

async def pringle(): 
    dcp = pm.globalThis.dcp
    # define the compute workload (job)
    job = dcp.compute['for'](data, work_function, args2)

    # add event listeners for debug logs
    job.on('readystatechange', print)
    job.on('accepted', lambda: print(job.id))
    job.on('result', lambda x: print(f'New result for slice "{x.sliceNumber}" is "{x.result}"'))
    #job.computeGroups = [{ 'joinKey': 'joseph', 'joinSecret': 'pringle' }]

    # deploy the compute workload to the DCP network
    results = await job.exec()
    print(results)

dcp_client['init'](pringle)

sometimes I get

exec
init
preauth
deploying
Uncaught  Error: Assertion failure
    dcpAssert$$msgAssert@webpack://dcp/./src/common/dcp-assert.js?:90:21
    dcpAssert$$assert@webpack://dcp/./src/common/dcp-assert.js?:125:15
    Connection530$$shutdown@webpack://dcp/./src/protocol/connection.js?:398:9
    Connection530$$serviceTxQueue@webpack://dcp/./src/protocol/connection.js?:1518:10
    async*Connection530$$requestTxQueueService/<@webpack://dcp/./src/protocol/connection.js?:1404:22
    sendPromiseRejectWrapper@webpack://dcp/./src/protocol/connection.js?:1151:32
    DialogueRegistry$$clear@webpack://dcp/./src/protocol/dialogue-registry.js?:173:24
    finalize@webpack://dcp/./src/protocol/connection.js?:501:29
    Connection530$$shutdown/<@webpack://dcp/./src/protocol/connection.js?:404:24
    Connection530$$a$enqueue@webpack://dcp/./src/protocol/connection.js?:1134:27
    Connection530$$send@webpack://dcp/./src/protocol/connection.js?:1198:36
    DcpMessage$$send@webpack://dcp/./src/protocol/dcp-message.js?:58:26
    useDeployConnection@webpack://dcp/./src/dcp-client/job/index.js?:1542:41
    async*deployJob@webpack://dcp/./src/dcp-client/job/index.js?:1453:31
    async*exec@webpack://dcp/./src/dcp-client/job/index.js?:967:20

other times I get

exec
init
preauth
deploying
listeners
compute-groups
uploading
Uncaught undefined DCPError: no transports defined
    DCPError@webpack://dcp/./src/common/dcp-error.js?:22:5Connection530$$connectTransport@webpack://dcp/./src/protocol/connection.js?:827:22
    async*Connection530$$connectInternal@webpack://dcp/./src/protocol/connection.js?:759:16
    async*Connection530$$connect@webpack://dcp/./src/protocol/connection.js?:673:10
    Connection530$$send@webpack://dcp/./src/protocol/connection.js?:1186:15
    Connection530$$request@webpack://dcp/./src/protocol/connection.js?:1230:15
    provisionSubscriptionTokens@webpack://dcp/./src/events/event-subscriber.js?:218:48
    subscribeManyEvents@webpack://dcp/./src/events/event-subscriber.js?:298:18
    subscribeNewEvents@webpack://dcp/./src/dcp-client/job/index.js?:1233:32
    addInitialEvents@webpack://dcp/./src/dcp-client/job/index.js?:1186:16
    async*exec@webpack://dcp/./src/dcp-client/job/index.js?:968:39

  timestamp: 2024-08-28T20:56:51.583Z,
  code: 'DCPC-1014',
  process: 'oom-timers' undefined

then with this last one later get

deployed
0x267e50D18a2Ea8Dd6f67f650aF581D1aE89E53D2

both messages come repeatedly

philippedistributive commented 2 months ago

Uncaught undefined DCPError: no transports defined

was seen before and thought to be about the string corruption, so one out

philippedistributive commented 2 months ago

Possibly also the other issue is caused by string corruption issue