rojo-rbx / rojo

Rojo enables Roblox developers to use professional-grade software engineering tools
https://rojo.space
Mozilla Public License 2.0
906 stars 170 forks source link

Updates for Ref properties specified with attributes are always `null` in `/api/subscribe` responses #929

Open kennethloeffler opened 1 week ago

kennethloeffler commented 1 week ago

To reproduce:

  1. Run rojo plugin install
  2. Run rojo serve on the ref_properties test project
  3. Open a fresh baseplate in Roblox Studio, enable trace logging in the Rojo plugin, and click Connect
  4. Make any change to ref_properties' default.project.json (I added a newline)
  5. Observe the output, and notice that the subscribe response contains null for all the Ref properties specified with attributes in ref_properties' default.project.json:
    {
    "sessionId": "d264957a-76ce-486b-8df6-7151de8da0c1",
    "messageCursor": 2,
    "messages": [
    {
      "removed": [],
      "added": {},
      "updated": [
        {
          "id": "516ae8375fd349b4a61ac47529c969cf",
          "changedName": null,
          "changedClassName": null,
          "changedProperties": {
            "Value": null
          },
          "changedMetadata": null
        },
        {
          "id": "1aee8e1cc88e674f9917cc95e9d56bf6",
          "changedName": null,
          "changedClassName": null,
          "changedProperties": {
            "Value": null
          },
          "changedMetadata": null
        },
        {
          "id": "5e3e89750a0826e8d5d83b1ee86cad1a",
          "changedName": null,
          "changedClassName": null,
          "changedProperties": {
            "PrimaryPart": null
          },
          "changedMetadata": null
        },
        {
          "id": "04b43e42134d58c42408ff2b9ba1c9a4",
          "changedName": null,
          "changedClassName": null,
          "changedProperties": {
            "Value": null
          },
          "changedMetadata": null
        }
      ]
    }
    ]
    }

    I noticed this behavior in some test failures after #843 was merged: https://github.com/rojo-rbx/rojo/actions/runs/9605402645/job/26492956529#step:7:762. This makes it impossible for the Rojo plugin to live update a Ref property, could cause problems once rbx_dom_lua gains better ability to represent optional values, and can currently cause test failures on macOS due to seemingly inherent noisiness in FSEvents.

One reason this could happen is because deferred Ref property application appears to not influence the returned result of patch application (i.e. PatchApplyContext.applied_patch_set), but rather only influences the tree: https://github.com/rojo-rbx/rojo/blob/7e2bab921aa71f76d07d0424e4bb4064e8b7c995/src/snapshot/patch_apply.rs#L246-L299

It will also be worth investigating patch computation, to see if Ref properties specified via attributes are erroneously detected as removed there.