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

context.getPromiseState readme sample not working #210

Open
damianofalcioni opened this issue Oct 16, 2024 · 0 comments
Open

context.getPromiseState readme sample not working #210

damianofalcioni opened this issue Oct 16, 2024 · 0 comments

Comments

@damianofalcioni
Copy link

Hi,
I'm try to run the context.getPromiseState demo in the readme but I got the following error:

import { getQuickJS, shouldInterruptAfterDeadline } from 'quickjs-emscripten'

const QuickJS = await getQuickJS();
const context = QuickJS.newContext();

const promiseHandle = context.evalCode(`Promise.resolve(42)`);
const resultHandle = context.unwrapResult(context.getPromiseState(promiseHandle));
console.log(context.getNumber(resultHandle));
resultHandle.dispose();
promiseHandle.dispose();

context.dispose();

Error:

0
file:///.../node_modules/quickjs-emscripten-core/dist/chunk-JTKJZQYV.mjs:3
Lifetime used`):new QuickJSUseAfterFree("Lifetime not alive")}},StaticLifetime=class extends Lifetime{constructor(value,owner){super(value,void 0,void 0,owner)}get dupable(){return!0}dup(){return this}dispose(){}},WeakLifetime=class extends Lifetime{constructor(value,copier,disposer,owner){super(value,copier,disposer,owner)}dispose(){this._alive=!1}};function scopeFinally(scope,blockError){let disposeError;try{scope.dispose()}catch(error){disposeError=error}if(blockError&&disposeError)throw Object.assign(blockError,{message:`${blockError.message}
                ^

QuickJSUseAfterFree: Lifetime not alive
    at _Lifetime.assertAlive (file:///.../node_modules/quickjs-emscripten-core/dist/chunk-JTKJZQYV.mjs:3:17)
    at _Lifetime.dispose (file:///.../node_modules/quickjs-emscripten-core/dist/chunk-JTKJZQYV.mjs:1:4093)
    at DisposableSuccess.dispose (file:///.../node_modules/quickjs-emscripten-core/dist/chunk-JTKJZQYV.mjs:4:2379)
    at file:///.../src/connectors/js-quickjs/index.js:10:15

Node.js v20.16.0

Also the intellisense report an error on context.getPromiseState(promiseHandle):

Argument of type 'JSPromiseState' is not assignable to parameter of type 'SuccessOrFail<QuickJSHandle, QuickJSHandle>'.
  Type 'JSPromiseStatePending' is not assignable to type 'SuccessOrFail<QuickJSHandle, QuickJSHandle>'.
    Property 'value' is missing in type 'JSPromiseStatePending' but required in type '{ value: QuickJSHandle; error?: undefined; }'.

quickjs-emscripten version: 0.31.0

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant