deepstream.io icon indicating copy to clipboard operation
deepstream.io copied to clipboard

ACK_TIMEOUT with Valve permissions, cross references, subscript operator

Open ChristophConrads-deepstreamHub opened this issue 9 years ago • 8 comments

Zipped demo code

Consider the following snippet from a Valve file:

record:
  "d/$uid":
    create: _('perm/' + user.id)[$uid]
    read:   _('perm/' + user.id)[$uid]
  "*":
    create: true
    write: true
    read: true
    delete: true
    listen: true

If the client attempts to get a non-existent record d/$uid with, e.g., client.record.getRecord("d/u101"), then the server seems to hang, triggering the client's error handler:

handleError d/u101 ACK_TIMEOUT R

The error can be avoided by removing either line 3 or line 4 from the Valve code above.

Simplified demo: subscript-operator.zip

permissions.yml:

record:
  "d/*":
    create: _('perm/JohnDoe').boolean
    read:   _('perm/JohnDoe').boolean
  "*":
    create: true
    write: true
    read: true
    delete: true
    listen: true

The issue only occurs with special rules for create and read but no other combination.

Is this bug only in v2.1.0? As a workaround should one switch to 2.0.0?

abhinavzspace avatar Dec 27 '16 17:12 abhinavzspace

The issue occurs with

  • deepstream.io 2.0.0 npm,
  • deepstream.io 2.0.1 npm,
  • deepstream.io 2.1.0 npm, and
  • deepstream.io 2.0.1 OS X standalone binary.

The client can be made to report a RESPONSE_TIMEOUT error by increasing recordReadAckTimeout beyond 3000 (the default value for recordReadTimeout):

const options = {
	recordReadAckTimeout: 10000, // default: 1000
	recordReadTimeout: 5000 // default: 3000
};
const deepstream = require('deepstream.io-client-js');
const client = deepstream('localhost:6020', options);

This seems to be a very basic functionality. How are everybody working with dynamic permissions if this is not working? May be I am trying to do things the wrong way. What is the best practice for implementing dynamic permissions?

abhinavzspace avatar Dec 28 '16 02:12 abhinavzspace

@abhinavzspace what type of cache layer are you using? The default internal one?

yasserf avatar Dec 28 '16 10:12 yasserf

Fixed in master, i thought it was due to sync cache but that was a red herring. It appears this issue happens as a race condition where it checks the next permission before a destroy is called on the previous.

yasserf avatar Dec 28 '16 10:12 yasserf