Graphcool / graphcool-framework

Apache License 2.0
1.77k stars 131 forks source link

No subscription fail if not success #495

Open leedan77 opened 6 years ago

leedan77 commented 6 years ago

Environment Cluster: ap-northeast Device: react native(both ios, android), chrome

Current behavior The subsciption fail to listen sometimes using "Type subscription", but no error message. So I try to discover debug message between graphcool cloud, using plain websocket. image

The subscription fail to listen to new data, but doesn't get either 'subscription_success' or 'subscription_fail'. While subscription success printed, the behavior is normal as expected.

Reproduction

Using plain websocket implemetation from graphcool doc.

webSocket.onmessage = (event) => {
  const data = JSON.parse(event.data)

  switch (data.type) {
    case 'init_success': {
      console.log('init_success, the handshake is complete')
      break
    }
    case 'init_fail': {
      throw {
        message: 'init_fail returned from WebSocket server',
        data
      }
    }
    case 'subscription_data': {
      console.log('subscription data has been received', data)
      break
    }
    case 'subscription_success': {
      console.log('subscription_success')
      break
    }
    case 'subscription_fail': {
      throw {
        message: 'subscription_fail returned from WebSocket server',
        data
      }
    }
  }
}

Expected behavior? The subscription should fail in "onmessage" event if it couldn't return the correct result.