Skip to content

Commit b69680a

Browse files
committed
fix(event-loop): fix the Future object is not initialized error and the segfault that follows
It's still a reference count issue as always. When JS throws an error in a Promise wrapper, it will only show the actual JS error instead of a Python exception `asyncio.exceptions.InvalidStateError: Future object is not initialized.`
1 parent c80f2ec commit b69680a

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/PyEventLoop.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ PyEventLoop::Future PyEventLoop::ensureFuture(PyObject *awaitable) {
119119
Py_DECREF(args);
120120
Py_DECREF(kwargs);
121121

122+
Py_INCREF(futureObj); // needs to be kept alive as `PyEventLoop::Future` will decrease the reference count in its destructor
122123
return PyEventLoop::Future(futureObj);
123124
}
124125

0 commit comments

Comments
 (0)