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

Unresolved promise in ECSchemaRpcLocater.getSchemaSync #7787

Open
laurynas111 opened this issue Feb 28, 2025 · 1 comment
Open

Unresolved promise in ECSchemaRpcLocater.getSchemaSync #7787

laurynas111 opened this issue Feb 28, 2025 · 1 comment
Labels
bug Something isn't working ecschema Issues related to the various ecschema packages

Comments

@laurynas111
Copy link
Contributor

Describe the bug
SchemaContext.getSchemaSync throws an exception possibly due to a bug of how Promises are handled in ECSchemaRpcLocater.getSchemaSync

To Reproduce

  1. Call SchemaContext.getSchemaSync method
  2. An error with "An ECSchema is missing the require 'name' attribute" message is thrown

Expected behavior
Schema should be loaded Synchroniously

Desktop (please complete the applicable information):

  • OS: Windows 10
  • iTwin Studio 1.0.133
  • iTwin.js Version 4.10.6

Additional context
schemaJson is an instance of Promise. And is passed to Schema.fromJsonSync method.
Image

Since Schema.fromJsonSync can accept any object type, typescript compiler loses all info that the passed object is a Promise and is passed to reader.readSchemaSync as rawSchema
Image

The promise is then being treated as SchemaProps object which results in an exception

if (undefined === this._rawSchema.name)

@grigasp grigasp added bug Something isn't working ecschema Issues related to the various ecschema packages labels Feb 28, 2025
@ColinKerr
Copy link
Member

I propose that we just replace the sync implementation with code that throws right away. You should only use the async method when locating a schema over rpc/http.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ecschema Issues related to the various ecschema packages
Projects
None yet
Development

No branches or pull requests

3 participants