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

calls to makeClientMarshaller share static mutable state #73

Open
dckc opened this issue Jan 1, 2024 · 0 comments
Open

calls to makeClientMarshaller share static mutable state #73

dckc opened this issue Jan 1, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@dckc
Copy link
Member

dckc commented Jan 1, 2024

Describe the bug

Calls to makeClientMarshaller share static mutable state: the results of 1 call to makeTranslationTable(...).

To Reproduce

This test fails:

test('calls to makeClientMarshaller do not share static mutable state', () => {
  const m1 = makeClientMarshaller();
  const m2 = makeClientMarshaller();
  const capData = { body: '#"$0.Brand"', slots: ['board0123'] };
  // b1 is a fresh synthetic remotable object
  const b1 = m1.fromCapData(capData);
  // unless m2 somehow has access to state from m1, m2 can't access b1.
  const b2 = m2.fromCapData(capData);
  expect(b1).not.toBe(b2);
});

Expected behavior

The call to makeTranslationTable(...) should be inside makeClientMarshaller.

Exported function such as makeClientMarshaller should not close over static mutable state.
This follows from anything globally accessible is immutable data in OCap Discipline.

Platform Environment

  • what OS are you using? what version of Node.js?
    v18.17.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant