New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@clevercloud/client

Package Overview
Dependencies
Maintainers
6
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@clevercloud/client - npm Package Compare versions

Comparing version

to
2.0.0-beta.4

4

CHANGELOG.md
# Clever Client changelog
## 2.0.0-beta.4 (2019-08-28)
- Fix SSE (add a timeout when opening a stream)
## 2.0.0-beta.3 (2019-08-23)

@@ -4,0 +8,0 @@

@@ -14,2 +14,4 @@ "use strict";

const OPEN_TIMEOUT = 3000;
class AbstractLogsStream extends _streamAbstract.AbstractStream {

@@ -91,4 +93,8 @@ constructor({

} = await this.prepareLogsSse();
const sse = this.createEventSource(url);
const sse = this.createEventSource(url); // Sometimes, the EventSource is open but no messages are returned and no errors thrown
// We wait for OPEN_TIMEOUT before considering the EventSource
// if no message or error is received by then, we close the stream
const openTimeoutId = setTimeout(doClose, OPEN_TIMEOUT);
function doClose(reason) {

@@ -100,2 +106,3 @@ sse.close();

sse.addEventListener('message', message => {
clearTimeout(openTimeoutId);
const parsedMessage = this.parseLogMessage(message);

@@ -105,2 +112,3 @@ this.isPingMessage(parsedMessage) ? onPing(parsedMessage.heartbeat_delay_ms) : onMessage(parsedMessage);

sse.addEventListener('error', err => {
clearTimeout(openTimeoutId);
this.isAuthErrorMessage(err) ? doClose(_streamAbstract.AUTHENTICATION_REASON) : doClose();

@@ -107,0 +115,0 @@ });

@@ -5,2 +5,4 @@ import { AbstractStream, AUTHENTICATION_REASON } from './stream.abstract.js';

const OPEN_TIMEOUT = 3000;
export class AbstractLogsStream extends AbstractStream {

@@ -79,2 +81,7 @@

// Sometimes, the EventSource is open but no messages are returned and no errors thrown
// We wait for OPEN_TIMEOUT before considering the EventSource
// if no message or error is received by then, we close the stream
const openTimeoutId = setTimeout(doClose, OPEN_TIMEOUT);
function doClose (reason) {

@@ -86,2 +93,3 @@ sse.close();

sse.addEventListener('message', (message) => {
clearTimeout(openTimeoutId);
const parsedMessage = this.parseLogMessage(message);

@@ -94,2 +102,3 @@ this.isPingMessage(parsedMessage)

sse.addEventListener('error', (err) => {
clearTimeout(openTimeoutId);
this.isAuthErrorMessage(err)

@@ -96,0 +105,0 @@ ? doClose(AUTHENTICATION_REASON)

2

package.json
{
"name": "@clevercloud/client",
"version": "2.0.0-beta.3",
"version": "2.0.0-beta.4",
"description": "JavaScript REST client and utils for Clever Cloud's API",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/CleverCloud/clever-client.js",