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

add warning to multiple sdk instances with the same parameters #566

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Kelerchian
Copy link
Contributor

No description provided.

Copy link
Contributor

@jmg-duarte jmg-duarte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly, this provides two "entry points" to the Actyx client. If that is the case, I feel that the behavior should be better documented for the user.

type Signature = AppManifest['signature']
type ActyxHost = ActyxOpts['actyxHost']
type ActyxPort = ActyxOpts['actyxPort']
type Param = [AppId, Version, Signature, ActyxHost, ActyxPort]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dislike the Param name, Params/Parameters makes much more sense given it's a list.

I'd also add a brief docstring

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these types aren’t visible to anyone, so a docstring won’t be displayed anywhere — did you mean a comment?

@Kelerchian
Copy link
Contributor Author

If I understand correctly, this provides two "entry points" to the Actyx client. If that is the case, I feel that the behavior should be better documented for the user.

No. This is purely an internal logging mechanism opaque to the user

const oldDispose = actyx.dispose
actyx.dispose = () => {
const result = oldDispose()
actyxInstanceRegister.subOne(manifest, opts)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does oldDispose() invoke some user callbacks? If so, such callback could try to create a new SDK instance, which in that case would log the “multiple connections” error. If correctness permits it, I’d do the subOne before the oldDispose.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It only calls MultiplexedWebsocket.dispose under the hood.
There should be no difference between both orders since this is a sync function.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My worry was that there might be an event emitted to user code from that sync function — and if we add such a thing in the future then this problem may well surface.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that's a valid concern

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed fc39630

type Signature = AppManifest['signature']
type ActyxHost = ActyxOpts['actyxHost']
type ActyxPort = ActyxOpts['actyxPort']
type Param = [AppId, Version, Signature, ActyxHost, ActyxPort]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these types aren’t visible to anyone, so a docstring won’t be displayed anywhere — did you mean a comment?

js/sdk/src/actyx.ts Outdated Show resolved Hide resolved
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.

[Feature]: Print warning when more than 1 SDK is created in a NodeJS/Browser runtime
3 participants