Skip to content

Memory leak in /base/style.json route #253

@allthesignals

Description

@allthesignals
  1. Run the app locally after fresh reboot, visit /v1/base/style.json. You'll notice it's the exact file in /data/base/style.json.
  2. Visit /v1/layer-groups. Then go back and reload /v1/base/style.json. Notice it's identical to /v1/layer-groups.

This is because of a memory leak located here:
image

This utility imports a "json" file then mutates it. Because the file extension is json, it suggests that it's static and immutable, but it's not — I think it's simply loaded into memory when the app boots and preserves whatever mutations were made the last time the route was loaded. That means /v1/base/style.json will return whatever tiles were generated for which app was last visited. In theory, you could be getting ZoLa style.json when you wanted FactFinder style.json. Spooky!

A quick fix would be create a local copy of style.json in consuming apps. Another approach might be to make a deep copy of style.json in this app. A third might be to look at how it loads static JSON elsewhere in the app using utils/local-resources-utilities/-load-json.js.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions