Skip to content

Conversation

@anotherjesse
Copy link
Contributor

@anotherjesse anotherjesse commented Apr 1, 2025

  • re-auth should re-enable bg flow
  • ensure the schemas match & cleanup (status was missing)
  • set status on enable/disable/worker error

image

@anotherjesse
Copy link
Contributor Author

@jsantell would love your review ...

@anotherjesse anotherjesse requested a review from jsantell April 1, 2025 21:26
@anotherjesse anotherjesse changed the title collection of cleanups schema fixes / status messages on failures Apr 1, 2025
Copy link
Collaborator

@jsantell jsantell left a comment

Choose a reason for hiding this comment

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

Nice! Mostly curious about how the write schema (recipes/bgAdmin.tsx) applies/interacts with the read schema (@commontools/utils/updaters#CharmEntrySchema)

bg.update({
disabledAt: Date.now(),
lastRun: Date.now(),
status: error ? error : "Disabled",
Copy link
Collaborator

@jsantell jsantell Apr 1, 2025

Choose a reason for hiding this comment

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

consider: error ?? "Disabled"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

deno typescript doesn't like it:

Property 'error' does not exist on type '{ success: boolean; data?: any; charmId: string; } | { success: boolean; error: string; charmId: string; } | { success: boolean; error: string; }'.

  Property 'error' does not exist on type '{ success: boolean; data?: any; charmId: string; }'.

deno-ts(2339)

Copy link
Collaborator

Choose a reason for hiding this comment

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

error is a string | undefined, not sure what that type is

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image

I think it might just be typescript being overly cautious?

}

export async function newGetFunc(): Promise<Cell<Cell<BGCharmEntry>[]>> {
export async function getBGUpdaterCharmsCell(): Promise<
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice renames here 👍

status: { type: "string" },
disabledAt: { type: "number", default: 0 },
lastRun: { type: "number", default: 0 },
status: { type: "string", default: "" },
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe worthwhile leaving a comment that this schema should (must?) match CharmEntrySchema in @commontools/utils/updaters

Probably a broader question, how does the worker code (via @commontools/utils/updaters) enforce/reject/ignore/handle data on read with a different written schema (e.g. BGCharmEntrySchema here)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good call - added the note

w.r.t. the broader question - as long as the schemas are additive the new defaults are loaded.

but I think we have to be careful - as I don't think anything stops us from breaking things with schema changes that aren't backwards compatible

@anotherjesse anotherjesse merged commit 51cb4a4 into main Apr 1, 2025
6 checks passed
@anotherjesse anotherjesse deleted the bg-schema-cleanups branch April 1, 2025 23:00
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

Successfully merging this pull request may close these issues.

4 participants