permaweb / aos

An operating system for AO: The hyper parallel computer
https://ao.g8way.io
Other
74 stars 53 forks source link

AOS Crash on unexpected non-string return value #400

Open nikooo777 opened 2 hours ago

nikooo777 commented 2 hours ago

Reproduction:

start a process, with the .editor set this code:

function ReturnTrueTable()
    return true, {a = "b"}
end

.done

call the function:

ReturnTrueTable()

observe the crash:

file:///home/niko/.nvm/versions/node/v20.15.0/lib/node_modules/@permaweb/aos/src/services/errors.js:22
  const errorMessage = error.replace(
                             ^

TypeError: error.replace is not a function
    at parseError (file:///home/niko/.nvm/versions/node/v20.15.0/lib/node_modules/@permaweb/aos/src/services/errors.js:22:30)
    at doEvaluate (file:///home/niko/.nvm/versions/node/v20.15.0/lib/node_modules/@permaweb/aos/src/index.js:533:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Interface.<anonymous> (file:///home/niko/.nvm/versions/node/v20.15.0/lib/node_modules/@permaweb/aos/src/index.js:415:9)

Node.js v20.15.0

Further information:

whenever a function returns two values, ao considers second argument an error message and tries to parse it:

result == {
  Messages: [],
  Assignments: [],
  Spawns: [],
  Output: '',
  GasUsed: 0,
  Error: { a: 'b' }
}

the quickest workaround is to return a single value.

nikooo777 commented 2 hours ago

we accidentally sent in the same issue twice. #399