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

No errors thrown when the worker is down #206

Open
Naeoth opened this issue Sep 28, 2018 · 3 comments
Open

No errors thrown when the worker is down #206

Naeoth opened this issue Sep 28, 2018 · 3 comments

Comments

@Naeoth
Copy link

Naeoth commented Sep 28, 2018

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request

Scope (check one with "x")

[ ] <root>
[ ] @zetapush/cli
[ ] @zetapush/client
[ ] @zetapush/cometd
[ ] @zetapush/common
[ ] @zetapush/core
[ ] @zetapush/create
[ ] @zetapush/http-server
[ ] @zetapush/platform-legacy
[ ] @zetapush/testing
[ ] @zetapush/troubleshooting
[x] @zetapush/user-management
[ ] @zetapush/worker

Current behavior

When the local worker is not running, no connection error is thrown on a user management method. The promise doesn't seem to end at all. Impossible to handle the case where the servers are unavailable. However, a client can establish a connection even if there is no worker. It's a little weird because I'm allowed to be connected with ZetaPush but I can't use the user-management.

Expected behavior

Put a timeout on the API method to throw an exception (maybe PlatformError ?) when the servers are not available and maybe not allow the connection if the worker is not running.

Minimal reproduction of the problem with instructions

  • Connect an user
  • Use a method from user-management

What is the motivation / use case for changing the behavior?

Handle the case where the servers are down

Please tell us about your environment:

  • Operating System:
  • Node Version: 10.8.0
  • Npm Version: 6.4.1
  • @zetapush/* Version: 34.2
@ghoullier
Copy link
Contributor

There is already a timeout mechanism on requests to ZetaPush platform.

const client = new ZetaPushClient.WeakClient();
const api = client.createProxyTaskService();
await client.connect();
console.log('connected'); // Will work even if worker is not started
try {
  const message = await api.hello();
} catch (error) {
  // This code will fail if worker is not started after a 10s timeout 
}

Timeout is configurable via createProxyTaskService

const api = client.createProxyTaskService({
  timeout: 1000
});

@Naeoth
Copy link
Author

Naeoth commented Sep 28, 2018

Doesn't seem to work for me with the user-management...
I use a custom AsyncTaskService for React Native. Does it have a default timeout ?

export default class UserManagementAsyncTaskService extends Queue {
  signup(p, ns) {
    return this.$publish('signup', p, ns);
  }
}
const client = new ZetaPushClient.WeakClient();
const api = client.createAsyncTaskService({ Type: UserManagementAsyncTaskService, namespace: 'user' });
await client.connect();
try {
await api.signup({
    credentials: { login: email, password },
    profile: {
      email,
    },
  });
} catch(error) {
// Never called
}

@Naeoth
Copy link
Author

Naeoth commented Oct 4, 2018

createProxyTaskService use timeoutify which set a timeout from the parameter but createAsyncTaskService use the class Timeout. This class doesn't seem to use any timeout in its code. I think the problem is here.

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

No branches or pull requests

2 participants