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

fix(backend-native): Handle closed channel on Rust side #9242

Merged
merged 1 commit into from
Feb 20, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion packages/cubejs-backend-native/js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,23 @@ function wrapNativeFunctionWithStream(
if (!!response && !!response.stream) {
response.stream.destroy(e);
}
writerOrChannel.reject(errorString(e));

try {
writerOrChannel.reject(errorString(e));
} catch (rejectError) {
// This is async function, just for usability, it's return value is not expected anywhere
// Rust part does not care for returned promises, so we should take care here to avoid unhandled rejections
// `writerOrChannel.reject` can throw when channel is already dropped by Rust side
// This can happen directly, when drop happened between creating channel and calling `reject`,
// or indirectly, when drop happened between creating channel and calling `resolve`, resolve raised an exception
// that was caught here
// There's nothing we can do, or should do with this: there's nobody to respond to
if (process.env.CUBEJS_NATIVE_INTERNAL_DEBUG) {
console.debug('[js] writerOrChannel.reject exception', {
e: rejectError,
});
}
}
}
};
}
Expand Down
Loading