Skip to content

Conversation

@anonrig
Copy link
Member

@anonrig anonrig commented Dec 22, 2025

No description provided.

@anonrig anonrig requested a review from mikea December 22, 2025 19:37
@anonrig anonrig requested review from a team as code owners December 22, 2025 19:37
@anonrig anonrig added the rust Pull requests that update rust code label Dec 22, 2025
@anonrig anonrig force-pushed the yagiz/support-non-result-return-vals branch from fa13c8a to 33688a1 Compare December 23, 2025 15:27
@github-actions
Copy link

github-actions bot commented Dec 23, 2025

The generated output of @cloudflare/workers-types matches the snapshot in types/generated-snapshot 🎉

@anonrig anonrig force-pushed the yagiz/support-non-result-return-vals branch from f1c9bcb to 95722ed Compare December 23, 2025 16:25
@codspeed-hq
Copy link

codspeed-hq bot commented Dec 23, 2025

CodSpeed Performance Report

Merging #5743 will improve performance by 12.69%

Comparing yagiz/support-non-result-return-vals (95722ed) with main (78a4eec)

Summary

⚡ 1 improvement
✅ 56 untouched
⏩ 34 skipped1

Benchmarks breakdown

Benchmark BASE HEAD Efficiency
simpleStringBody[Response] 22.4 µs 19.9 µs +12.69%

Footnotes

  1. 34 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

use crate::v8;
use crate::v8::ToLocalValue;

impl Type for String {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: let's move these impl Type below Wrappable definition

fn wrap(self, lock: &mut Lock) -> v8::Local<'_, v8::Value>;

/// Converts a JavaScript value into this Rust type.
fn unwrap(isolate: v8::IsolatePtr, value: v8::Local<v8::Value>) -> Self;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imo this should always return some Result, I'm not sure how will error handling work otherwise

/// Converts a JavaScript value into this Rust type.
fn unwrap(isolate: v8::IsolatePtr, value: v8::Local<v8::Value>) -> Self;

/// Attempts to unwrap a JavaScript value, returning None and throwing a JS error on failure.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does throwing a JS error mean here in Rust context? panic? we shouldn't write code that is expected to panic.

fn wrap(self, lock: &mut Lock) -> v8::Local<'_, v8::Value> {
match self {
Ok(value) => value.wrap(lock),
Err(_) => unreachable!("Cannot wrap Result::Err"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is it unreachable? this will also panic

}

fn unwrap(_isolate: v8::IsolatePtr, _value: v8::Local<v8::Value>) -> Self {
unreachable!("Cannot unwrap into Result")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here too: if this is unreachable then unwrap should not be part of Wrappable but be in Unwrappable. Otherwise someone will crash the code.

Copy link
Contributor

@mikea mikea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think error handling design needs a bit more love.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rust Pull requests that update rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants