Skip to content

Fix stale exports/imports/definitions after unregister_package#191

Merged
fibonacci1729 merged 2 commits intobytecodealliance:mainfrom
sumleo:fix/unregister-package-stale-exports
Feb 17, 2026
Merged

Fix stale exports/imports/definitions after unregister_package#191
fibonacci1729 merged 2 commits intobytecodealliance:mainfrom
sumleo:fix/unregister-package-stale-exports

Conversation

@sumleo
Copy link
Contributor

@sumleo sumleo commented Feb 12, 2026

Summary

  • unregister_package() called retain_nodes() to remove nodes but did not clean up the exports, defined, and imports maps
  • This left stale NodeIndex references that could cause panics or incorrect behavior when those maps were subsequently accessed
  • Now cleans up all three maps before removing nodes from the graph

Test plan

  • Added unit test it_cleans_up_exports_on_unregister_package that registers a package, exports a node, unregisters, and verifies cleanup
  • All existing tests pass (cargo test --workspace)

unregister_package() called retain_nodes() to remove nodes associated
with a package, but did not clean up the exports, defined, and imports
maps. This left stale NodeIndex references that could cause panics or
incorrect behavior when those maps were subsequently accessed.

Now cleans up all three maps before removing nodes from the graph.
Added a test that verifies exports are properly cleaned up after
unregistering a package.
@fibonacci1729 fibonacci1729 merged commit 45487dc into bytecodealliance:main Feb 17, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants