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

Remove JS SDK v1 #547

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Remove JS SDK v1 #547

wants to merge 1 commit into from

Conversation

jmg-duarte
Copy link
Contributor

@jmg-duarte jmg-duarte commented Oct 12, 2023

I was expecting to remove the SnapshotStore but it's still used in EventFnsFromEventStoreV2

},
{
"path": "../integration"
}
Copy link
Member

Choose a reason for hiding this comment

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

👍

// (Note that if the port is completely unreachable, v2getNodeId will throw an exception and we don’t get here.)
log.actyx.debug('NodeId was null, trying to reach V1 backend...')
return createV1(opts)
throw new Error('Node ID is missing')
Copy link
Member

Choose a reason for hiding this comment

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

I assume this is reached when there was a HTTP server but it returned the wrong response — it would help debugging such incidents to mention this in the error message.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can improve the call to v2getNodeId:

export const v2getNodeId = async (config: ActyxOpts): Promise<string | null> => {
  const path = `http://${getApiLocation(config.actyxHost, config.actyxPort)}/node/id`
  return await fetch(path)
    .then((resp) => {
      // null indicates the endpoint was reachable but did not react with OK response -> probably V1.
      return resp.ok ? resp.text() : null
    })
    .catch((err) => {
      // ECONNREFUSED is probably not a CORS issue, at least...
      if (err.message && err.message.includes('ECONNREFUSED')) {
        throw new Error(decorateEConnRefused(err.message, path))
      }

      log.actyx.info(
        'Attempt to connect to V2 failed with unclear cause. Gonna try go connect to V1 now. Error was:',
        err,
      )
      // HACK: V1 has broken CORS policy, this blocks our request if it reaches the WS port (4243) instead of the default port (4454).
      // So if we got an error, but the error is (probably) not due to the port being closed, we assume: Probably V1.
      // (Would be awesome if JS API gave a clear and proper indication of CORS block...)
      return null
    })
}

Maybe instead of checking for connection refused, we just remove the catch block so the error propagates up?

@Kelerchian
Copy link
Contributor

Not sure if this should be done now or later: bumping the version in package.json (and npm install-ing) afterwards before creating a commit to update package-lock.json

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.

None yet

3 participants