perf: send a schema reference in get-block-data instead of the full schema - #6402
Open
vshvets-bc wants to merge 1 commit into
Open
perf: send a schema reference in get-block-data instead of the full schema#6402vshvets-bc wants to merge 1 commit into
vshvets-bc wants to merge 1 commit into
Conversation
…chema
request-vc-document-block(-addon) getData embedded the full schema
(document + context) in every form block, so get-block-data responses
grew to tens of MB for policies with large schemas - parsed and
re-serialized across services and refetched by the client.
Emit a lightweight schema reference { id, iri, uuid, name, version };
the client resolves the full schema once by id (cached, de-duplicated)
via GET /schema/:id. The frontend is backward-compatible: a full schema
(document present) is used as before, so the client change is a no-op
until the backend sends a reference.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Pyatakov
requested changes
Jul 27, 2026
| data.schema = full; | ||
| this._applyBlockData(data); | ||
| }, | ||
| error: () => this._applyBlockData(data) |
Contributor
There was a problem hiding this comment.
On resolution failure this renders with the bare reference schema. new Schema(reference) has no document, so parseDocument() is skipped (interfaces/src/models/schema.ts:234) and fields stays empty so the user gets a silently blank form. Route the failure through the existing error handler instead:
Suggested change
| error: () => this._applyBlockData(data) | |
| error: (e) => this._onError(e) |
| data.schema = full; | ||
| super._onSuccess(data); | ||
| }, | ||
| error: () => super._onSuccess(data) |
Contributor
There was a problem hiding this comment.
Same issue as the non-addon block: on error this falls back to the reference schema (no document) and renders an empty form. Use error: (e) => this._onError(e) so the failure goes through the normal error/loading path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
requestVcDocumentBlockandrequestVcDocumentBlockAddongetData()embed the full schema (document+context) in every form block. For policies with large schemas the same schema is serialized once per form block, soget-block-dataresponses can reach tens of MB. That payload isJSON.parse/JSON.stringify-d as it is relayed between services (which do not read it), kept in memory on the client, and re-fetched on every block update — the repeated multi-MB serialization blocks the single Node event loop and slows unrelated requests.Change
Emit a lightweight schema reference
{ id, iri, uuid, name, version }instead of the fulldocument/context. The frontend resolves the full schema once by id (cached and de-duplicated) via the existingGET /schema/:id.get-block-dataresponses for schema-heavy forms.document) exactly as before, so the client change is a no-op until the backend sends a reference. The change is sequenced so the frontend can ship first.Details
request-vc-document-block.ts,request-vc-document-block-addon.ts—getDatareturns the reference.SchemaService.getSchemaById+ cached/de-duplicated/error-evictingresolveSchemaById;request-document-block(-addon)_onSuccessresolves a reference to the full schema before the existing render flow.Tests
request-vc-getdata-reference.test.mjs):getDataemits a reference, notdocument/context. Passing.schema.service.spec.ts): endpoint, concurrent-subscriber de-dup, cache-hit, and error-eviction/retry.Notes for reviewers
get-block-datathat relies on the embeddeddocument/context(e.g. remote/multi-policy interaction). Theid/iriare still present for anything that needs to look the schema up.