decentraland / decentraland/sdk

Sync scenes: crashes if the `getUserData` doesn't set a value before the `syncEntity` is called

Open
#1,082 0 comments 0 reactions 1 assignee Claimed by @gonpombo8 View on GitHub
bug new requires-tech-validation
Dominant language
No language data
Stars
4
Forks
5
PR merge metrics
No merged PRs in 30d

Description

This issue is happening in Godot (not sure in Bevy nor Explorer-Alpha). It works fine in the current reference client because the promise is resolved immediately (by kernel).

This error is logged by the `beer-dispenser` scene when it's spawned:
```
Error: Profile not initialized. Called syncEntity inside the main() function.
at syncEntity2 (file://~scene.js/:14225:13)
at main (file://~scene.js/:35761:3)
at Object._INTERNAL_startup_system [as fn] (file://~scene.js/:36162:26)
at Object.update (file://~scene.js/:12451:26)
at async Object.onUpdate (file://~scene.js/:36124:3) msg Some("Profile not initialized. Called syncEntity inside the main() function.") @ JsError { name: Some("Error"), message: Some("Profile not initialized. Called syncEntity inside the main() function."), stack: Some("Error: Profile not initialized. Called syncEntity inside the main() function.\n at syncEntity2 (file://~scene.js/:14225:13)\n at main (file://~scene.js/:35761:3)\n at Object._INTERNAL_startup_system [as fn] (file://~scene.js/:36162:26)\n at Object.update (file://~scene.js/:12451:26)\n at async Object.onUpdate (file://~scene.js/:36124:3)"), cause: None, exception_message: "Uncaught Error: Profile not initialized. Called syncEntity inside the main() function.", frames: [], source_line: None, source_line_frame_index: None, aggregated: None
```

The SDK is trying to get the primary player profile information `async`, while the `main` function is called in the first tick, sync after evaluation (https://adr.decentraland.org/adr/ADR-133).

A possible fix would be to use `PlayerIdentityData.get(engine.PlayerEntity)` to get primary player data.
Other option is to implement retries until the player data is available since the async function can take a bit.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.