Skip to content

Fix check watches after protobuf-es change#71

Merged
tstirrat15 merged 1 commit intomainfrom
fix-check-watches
May 27, 2025
Merged

Fix check watches after protobuf-es change#71
tstirrat15 merged 1 commit intomainfrom
fix-check-watches

Conversation

@tstirrat15
Copy link
Contributor

Description

Follow-on to #70. I reached for the wrong helper functions for serialization/deserialization, which meant that the comparisons were wrong. This fixes that.

Changes

Will annotate.

Testing

Review. See that check watches still work as expected locally.

@vercel
Copy link

vercel bot commented May 27, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 27, 2025 10:36pm

Copy link
Contributor Author

@tstirrat15 tstirrat15 left a comment

Choose a reason for hiding this comment

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

See comments.

Comment on lines -302 to +305
set.forEach((value: string | null) => {
deduped.push(value!);
});
return deduped;
return Array.from(set);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I simplified this construction and removed the type assertion on line 303 by using a type predicate (the notNull function and its value is string syntax).

JSON.parse(encodedResponse),
);
const response = fromJsonString(DeveloperResponseSchema, encodedResponse, {
ignoreUnknownFields: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ignoreUnknownFields is because the fromJsonString function was complaining that duration was an unknown field (down in the check debug output). It isn't used in this app, so I'm telling the function to ignore it.

Comment on lines -235 to -238
const response = create(
DeveloperResponseSchema,
JSON.parse(encodedResponse),
);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was the problem - the value that comes back from the WASM service has a string value for one of its enum values, and typescript (and by extension the underlying JS) were treating those enums as ints. Using fromJsonString coerces that value to the correct enum value, which means that you can then compare to a static enum value. This check in particular was the one that was failing, because with the old code the LHS of that comparison was the string "MEMBER" instead of the numeric enum value.

const developerRequest = JSON.stringify(
toJson(DeveloperRequestSchema, request),
);
const developerRequest = toJsonString(DeveloperRequestSchema, request);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also found this function while I was doing this work, and it seems like a better expression of what I'm trying to do.

Copy link
Member

@josephschorr josephschorr left a comment

Choose a reason for hiding this comment

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

LGTM

@tstirrat15 tstirrat15 merged commit 7e4cfa6 into main May 27, 2025
5 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators May 27, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants