workadventure / workadventure

A collaborative web application (virtual office) presented as a 16-bit RPG video game
https://workadventu.re
4.17k stars 621 forks source link

Crash in pusher + duplicate users #3072

Closed moufmouf closed 1 year ago

moufmouf commented 1 year ago

Today, in staging environment:

One pusher crashed.

When the pusher crashed, doppelgangers were created (probably doppelgangers of the users on the pusher that crashed).

image

When checking the /dump in the back server, Valdo does appear twice.

Hypothesis: the back did not detect successfully that the pusher is down and did not free / remove users registered in the pusher.

Logs of the pusher that crashed:

Error on getting map details AxiosError: Request failed with status code 404
      responseUrl: 'https://staging.workadventu.re/api/map?playUri=https:%2F%2Fplay.staging.workadventu.re%2F',
      redirects: [],
      [Symbol(kCapture)]: false,
      [Symbol(kHeaders)]: [Object],
      [Symbol(kHeadersCount)]: 18,
      [Symbol(kTrailers)]: null,
      [Symbol(kTrailersCount)]: 0
    },
    aborted: false,
    timeoutCb: null,
    upgradeOrConnect: false,
    parser: null,
    maxHeadersCount: null,
    reusedSocket: false,
    host: 'staging.workadventu.re',
    protocol: 'https:',
    _redirectable: Writable {
      _writableState: [WritableState],
      _events: [Object: null prototype],
      _eventsCount: 3,
      _maxListeners: undefined,
      _options: [Object],
      _ended: true,
      _ending: true,
      _redirectCount: 0,
      _redirects: [],
      _requestBodyLength: 0,
      _requestBodyBuffers: [],
      _onNativeResponse: [Function (anonymous)],
    at settle (/usr/src/node_modules/axios/lib/core/settle.js:19:12)
    at IncomingMessage.handleStreamEnd (/usr/src/node_modules/axios/lib/adapters/http.js:548:11)
      _currentRequest: [Circular *1],
    at IncomingMessage.emit (node:events:525:35)
      _currentUrl: 'https://staging.workadventu.re/api/map?playUri=https:%2F%2Fplay.staging.workadventu.re%2F',
    at IncomingMessage.emit (node:domain:489:12)
    at endReadableNT (node:internal/streams/readable:1359:12)
    at processTicksAndRejections (node:internal/process/task_queues:82:21) {
      [Symbol(kCapture)]: false
  code: 'ERR_BAD_REQUEST',
  config: {
    transitional: {
    },
    [Symbol(kCapture)]: false,
    [Symbol(kBytesWritten)]: 0,
    [Symbol(kEndCalled)]: true,
      silentJSONParsing: true,
      forcedJSONParsing: true,
      clarifyTimeoutError: false
    },
    adapter: [ 'xhr', 'http' ],
    transformRequest: [ [Function: transformRequest] ],
    transformResponse: [ [Function: transformResponse] ],
    timeout: 0,
    xsrfCookieName: 'XSRF-TOKEN',
    [Symbol(kNeedDrain)]: false,
    xsrfHeaderName: 'X-XSRF-TOKEN',
    maxContentLength: -1,
    maxBodyLength: -1,
    env: { FormData: [Function], Blob: [class Blob] },
    [Symbol(corked)]: 0,
    validateStatus: [Function: validateStatus],
    [Symbol(kOutHeaders)]: [Object: null prototype] {
    headers: AxiosHeaders {
      accept: [Array],
      Accept: 'application/json, text/plain, */*',
      authorization: [Array],
      Authorization: 'zpxngfjebcoehe4f5eke',
      'accept-language': [Array],
      'Accept-Language': 'en',
      'user-agent': [Array],
      'User-Agent': 'axios/1.3.2',
      'accept-encoding': [Array],
      host: [Array]
    },
    [Symbol(kUniqueHeaders)]: null
  },
      'Accept-Encoding': 'gzip, compress, deflate, br'
    },
    params: {
  response: {
    status: 404,
    statusText: 'Not Found',
    headers: AxiosHeaders {
      date: 'Fri, 17 Feb 2023 13:35:33 GMT',
      'content-type': 'application/json',
      'transfer-encoding': 'chunked',
      playUri: 'https://play.staging.workadventu.re/',
      connection: 'close',
      vary: 'Authorization',
      userId: undefined,
      'x-powered-by': 'PHP/8.2.2',
      'cache-control': 'no-cache, private',
      'access-control-allow-origin': '*',
      'strict-transport-security': 'max-age=15724800; includeSubDomains'
    },
    config: {
      transitional: [Object],
      adapter: [Array],
      transformRequest: [Array],
      transformResponse: [Array],
      accessToken: undefined
      timeout: 0,
    },
      xsrfCookieName: 'XSRF-TOKEN',
      xsrfHeaderName: 'X-XSRF-TOKEN',
    method: 'get',
      maxContentLength: -1,
    url: 'https://staging.workadventu.re/api/map',
      maxBodyLength: -1,
    data: undefined
      env: [Object],
  },
      validateStatus: [Function: validateStatus],
  request: <ref *1> ClientRequest {
      headers: [AxiosHeaders],
    _events: [Object: null prototype] {
      params: [Object],
      abort: [Function (anonymous)],
      method: 'get',
      aborted: [Function (anonymous)],
      url: 'https://staging.workadventu.re/api/map',
      connect: [Function (anonymous)],
      error: [Function (anonymous)],
      data: undefined
    },
    request: <ref *1> ClientRequest {
      socket: [Function (anonymous)],
      _events: [Object: null prototype],
      timeout: [Function (anonymous)],
      _eventsCount: 7,
      finish: [Function: requestOnFinish]
      _maxListeners: undefined,
    },
      outputData: [],
    _eventsCount: 7,
    _maxListeners: undefined,
      outputSize: 0,
    outputData: [],
    outputSize: 0,
      writable: true,
      destroyed: false,
      _last: true,
      chunkedEncoding: false,
      shouldKeepAlive: false,
      maxRequestsOnConnectionReached: false,
      _defaultKeepAlive: true,
      useChunkedEncodingByDefault: false,
      sendDate: false,
      _removedConnection: false,
      _removedContLen: false,
      _removedTE: false,
      strictContentLength: false,
      _contentLength: 0,
      _hasBody: true,
      _trailer: '',
      finished: true,
      _headerSent: true,
    writable: true,
      _closed: false,
      socket: [TLSSocket],
    destroyed: false,
    _last: true,
    chunkedEncoding: false,
      _header: 'GET /api/map?playUri=https:%2F%2Fplay.staging.workadventu.re%2F HTTP/1.1\r\n' +
    shouldKeepAlive: false,
    maxRequestsOnConnectionReached: false,
    _defaultKeepAlive: true,
    useChunkedEncodingByDefault: false,
    sendDate: false,
    _removedConnection: false,
    _removedContLen: false,
    _removedTE: false,
    strictContentLength: false,
        'Accept: application/json, text/plain, */*\r\n' +
    _contentLength: 0,
        'Authorization: zpxngfjebcoehe4f5eke\r\n' +
    _hasBody: true,
    _trailer: '',
        'Accept-Language: en\r\n' +
    finished: true,
        'User-Agent: axios/1.3.2\r\n' +
    _headerSent: true,
        'Accept-Encoding: gzip, compress, deflate, br\r\n' +
        'Host: staging.workadventu.re\r\n' +
        'Connection: close\r\n' +
    _closed: false,
        '\r\n',
      _keepAliveTimeout: 0,
    socket: TLSSocket {
      _onPendingData: [Function: nop],
      _tlsOptions: [Object],
      agent: [Agent],
      _secureEstablished: true,
      socketPath: undefined,
      method: 'GET',
      _securePending: false,
      _newSessionPending: false,
      maxHeaderSize: undefined,
      _controlReleased: true,
      secureConnecting: false,
      _SNICallback: null,
      servername: 'staging.workadventu.re',
      alpnProtocol: false,
      authorized: true,
      insecureHTTPParser: undefined,
      authorizationError: null,
      path: '/api/map?playUri=https:%2F%2Fplay.staging.workadventu.re%2F',
      encrypted: true,
      _ended: true,
      _events: [Object: null prototype],
      res: [IncomingMessage],
      _eventsCount: 10,
      aborted: false,
      connecting: false,
      timeoutCb: null,
      upgradeOrConnect: false,
      parser: null,
      _hadError: false,
      maxHeadersCount: null,
      _parent: null,
      reusedSocket: false,
      _host: 'staging.workadventu.re',
      host: 'staging.workadventu.re',
      _closeAfterHandlingError: false,
      protocol: 'https:',
      _readableState: [ReadableState],
      _redirectable: [Writable],
      _maxListeners: undefined,
      _writableState: [WritableState],
      [Symbol(kCapture)]: false,
      allowHalfOpen: false,
      [Symbol(kBytesWritten)]: 0,
      [Symbol(kEndCalled)]: true,
      _sockname: null,
      [Symbol(kNeedDrain)]: false,
      _pendingData: null,
      [Symbol(corked)]: 0,
      _pendingEncoding: '',
      server: undefined,
      _server: null,
      ssl: [TLSWrap],
      _requestCert: true,
      [Symbol(kOutHeaders)]: [Object: null prototype],
      _rejectUnauthorized: true,
      parser: null,
      _httpMessage: [Circular *1],
      [Symbol(res)]: [TLSWrap],
      [Symbol(verified)]: true,
      [Symbol(pendingSession)]: null,
      [Symbol(async_id_symbol)]: 426674,
      [Symbol(kHandle)]: [TLSWrap],
      [Symbol(lastWriteQueueSize)]: 0,
      [Symbol(kUniqueHeaders)]: null
    },
      [Symbol(timeout)]: null,
      [Symbol(kBuffer)]: null,
      [Symbol(kBufferCb)]: null,
      [Symbol(kBufferGen)]: null,
      [Symbol(kCapture)]: false,
      [Symbol(kSetNoDelay)]: false,
      [Symbol(kSetKeepAlive)]: true,
      [Symbol(kSetKeepAliveInitialDelay)]: 60,
      [Symbol(kBytesRead)]: 0,
      [Symbol(kBytesWritten)]: 0,
      [Symbol(connect-options)]: [Object]
    },
    _header: 'GET /api/map?playUri=https:%2F%2Fplay.staging.workadventu.re%2F HTTP/1.1\r\n' +
      'Accept: application/json, text/plain, */*\r\n' +
      'Authorization: zpxngfjebcoehe4f5eke\r\n' +
      'Accept-Language: en\r\n' +
      'User-Agent: axios/1.3.2\r\n' +
      'Accept-Encoding: gzip, compress, deflate, br\r\n' +
    data: {
      type: 'error',
      code: 'WORLD_NOT_FOUND',
      title: 'ERROR',
      'Host: staging.workadventu.re\r\n' +
      subtitle: 'No world could be found.',
      details: 'If you would like more information, you can contact the administrator or us at hello@workadventu.re',
      image: 'https://staging.workadventu.re/images/error.gif'
    }
  }
}
      'Connection: close\r\n' +
      '\r\n',
    _keepAliveTimeout: 0,
    _onPendingData: [Function: nop],
    agent: Agent {
      _events: [Object: null prototype],
      _eventsCount: 2,
      _maxListeners: undefined,
      defaultPort: 443,
      protocol: 'https:',
      options: [Object: null prototype],
      requests: [Object: null prototype] {},
      sockets: [Object: null prototype],
      freeSockets: [Object: null prototype] {},
      keepAliveMsecs: 1000,
      keepAlive: false,
      maxSockets: Infinity,
      maxFreeSockets: 256,
      scheduling: 'lifo',
      maxTotalSockets: Infinity,
      totalSocketCount: 1,
      maxCachedSessions: 100,
      _sessionCache: [Object],
      [Symbol(kCapture)]: false
    },
    socketPath: undefined,
    method: 'GET',
    maxHeaderSize: undefined,
    insecureHTTPParser: undefined,
    path: '/api/map?playUri=https:%2F%2Fplay.staging.workadventu.re%2F',
    _ended: true,
    res: IncomingMessage {
      _readableState: [ReadableState],
      _events: [Object: null prototype],
      _eventsCount: 4,
      _maxListeners: undefined,
      socket: [TLSSocket],
      httpVersionMajor: 1,
      httpVersionMinor: 1,
      httpVersion: '1.1',
      complete: true,
      rawHeaders: [Array],
      rawTrailers: [],
      aborted: false,
      upgrade: false,
      url: '',
      method: null,
      statusCode: 404,
      statusMessage: 'Not Found',
      client: [TLSSocket],
      _consuming: true,
      _dumped: false,
      req: [Circular *1],
      responseUrl: 'https://staging.workadventu.re/api/map?playUri=https:%2F%2Fplay.staging.workadventu.re%2F',
      redirects: [],
      [Symbol(kCapture)]: false,
      [Symbol(kHeaders)]: [Object],
      [Symbol(kHeadersCount)]: 18,
      [Symbol(kTrailers)]: null,
      [Symbol(kTrailersCount)]: 0
    },
    aborted: false,
    timeoutCb: null,
    upgradeOrConnect: false,
    parser: null,
    maxHeadersCount: null,
    reusedSocket: false,
    host: 'staging.workadventu.re',
    protocol: 'https:',
    _redirectable: Writable {
      _writableState: [WritableState],
      _events: [Object: null prototype],
      _eventsCount: 3,
      _maxListeners: undefined,
      _options: [Object],
      _ended: true,
      _ending: true,
      _redirectCount: 0,
      _redirects: [],
      _requestBodyLength: 0,
      _requestBodyBuffers: [],
      _onNativeResponse: [Function (anonymous)],
      _currentRequest: [Circular *1],
      _currentUrl: 'https://staging.workadventu.re/api/map?playUri=https:%2F%2Fplay.staging.workadventu.re%2F',
      [Symbol(kCapture)]: false
    },
    [Symbol(kCapture)]: false,
    [Symbol(kBytesWritten)]: 0,
    [Symbol(kEndCalled)]: true,
    [Symbol(kNeedDrain)]: false,
    [Symbol(corked)]: 0,
    [Symbol(kOutHeaders)]: [Object: null prototype] {
      accept: [Array],
      authorization: [Array],
      'accept-language': [Array],
      'user-agent': [Array],
      'accept-encoding': [Array],
      host: [Array]
    },
    [Symbol(kUniqueHeaders)]: null
  },
  response: {
    status: 404,
    statusText: 'Not Found',
    headers: AxiosHeaders {
      date: 'Fri, 17 Feb 2023 13:35:33 GMT',
      'content-type': 'application/json',
      'transfer-encoding': 'chunked',
      connection: 'close',
      vary: 'Authorization',
      'x-powered-by': 'PHP/8.2.2',
      'cache-control': 'no-cache, private',
      'access-control-allow-origin': '*',
      'strict-transport-security': 'max-age=15724800; includeSubDomains'
    },
    config: {
      transitional: [Object],
      adapter: [Array],
      transformRequest: [Array],
      transformResponse: [Array],
      timeout: 0,
      xsrfCookieName: 'XSRF-TOKEN',
      xsrfHeaderName: 'X-XSRF-TOKEN',
      maxContentLength: -1,
      maxBodyLength: -1,
      env: [Object],
      validateStatus: [Function: validateStatus],
      headers: [AxiosHeaders],
      params: [Object],
      method: 'get',
      url: 'https://staging.workadventu.re/api/map',
      data: undefined
    },
    request: <ref *1> ClientRequest {
      _events: [Object: null prototype],
      _eventsCount: 7,
      _maxListeners: undefined,
      outputData: [],
      outputSize: 0,
      writable: true,
      destroyed: false,
      _last: true,
      chunkedEncoding: false,
      shouldKeepAlive: false,
      maxRequestsOnConnectionReached: false,
      _defaultKeepAlive: true,
      useChunkedEncodingByDefault: false,
      sendDate: false,
      _removedConnection: false,
      _removedContLen: false,
      _removedTE: false,
      strictContentLength: false,
      _contentLength: 0,
      _hasBody: true,
      _trailer: '',
      finished: true,
      _headerSent: true,
      _closed: false,
      socket: [TLSSocket],
      _header: 'GET /api/map?playUri=https:%2F%2Fplay.staging.workadventu.re%2F HTTP/1.1\r\n' +
        'Accept: application/json, text/plain, */*\r\n' +
        'Authorization: zpxngfjebcoehe4f5eke\r\n' +
        'Accept-Language: en\r\n' +
        'User-Agent: axios/1.3.2\r\n' +
        'Accept-Encoding: gzip, compress, deflate, br\r\n' +
        'Host: staging.workadventu.re\r\n' +
        'Connection: close\r\n' +
        '\r\n',
      _keepAliveTimeout: 0,
      _onPendingData: [Function: nop],
      agent: [Agent],
      socketPath: undefined,
      method: 'GET',
      maxHeaderSize: undefined,
      insecureHTTPParser: undefined,
      path: '/api/map?playUri=https:%2F%2Fplay.staging.workadventu.re%2F',
      _ended: true,
      res: [IncomingMessage],
      aborted: false,
      timeoutCb: null,
      upgradeOrConnect: false,
      parser: null,
      maxHeadersCount: null,
      reusedSocket: false,
      host: 'staging.workadventu.re',
      protocol: 'https:',
      _redirectable: [Writable],
      [Symbol(kCapture)]: false,
      [Symbol(kBytesWritten)]: 0,
      [Symbol(kEndCalled)]: true,
      [Symbol(kNeedDrain)]: false,
      [Symbol(corked)]: 0,
      [Symbol(kOutHeaders)]: [Object: null prototype],
      [Symbol(kUniqueHeaders)]: null
    },
    data: {
      type: 'error',
      code: 'WORLD_NOT_FOUND',
      title: 'ERROR',
      subtitle: 'No world could be found.',
      details: 'If you would like more information, you can contact the administrator or us at hello@workadventu.re',
      image: 'https://staging.workadventu.re/images/error.gif'
    }
  }
}
TypeError [ERR_INVALID_URL]: Invalid URL
    at new NodeError (node:internal/errors:393:5)
    at URL.onParseError (node:internal/url:565:9)
    at new URL (node:internal/url:645:5)
    at dispatchHttpRequest (/usr/src/node_modules/axios/lib/adapters/http.js:186:20)
    at new Promise (<anonymous>)
    at http (/usr/src/node_modules/axios/lib/adapters/http.js:122:10)
    at Axios.dispatchRequest (/usr/src/node_modules/axios/lib/core/dispatchRequest.js:51:10)
    at Axios.request (/usr/src/node_modules/axios/lib/core/Axios.js:142:33)
    at Axios.<computed> [as get] (/usr/src/node_modules/axios/lib/core/Axios.js:168:17)
    at Function.wrap [as get] (/usr/src/node_modules/axios/lib/helpers/bind.js:5:15) {
  input: 'http://',
  code: 'ERR_INVALID_URL'
}
npm ERR! Lifecycle script `start` failed with error: 
npm ERR! Error: command failed 
npm ERR!   in workspace: workadventure-play@1.14.9 
npm ERR!   at location: /usr/src/play 
npm notice 
npm notice New major version of npm available! 8.19.2 -> 9.5.0
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v9.5.0>
npm notice Run `npm install -g npm@9.5.0` to update!
npm notice 

> workadventure-play@1.14.9 start
> TS_NODE_PROJECT=tsconfig-pusher.json ts-node --transpileOnly ./src/server.ts

Admin api is enabled at https://staging.workadventu.re. Will check connection and capabilities
Nolway commented 1 year ago

Maybe due to the map url fetching on /play/src/pusher/services/MetaTagsBuilder.ts line 276 :

private async fetchMapFile(): Promise<ITiledMap | undefined> {
        // Note: we could probably read the map file ONLY if the request comes from a bot.
        // Otherwise, the map file is already read in the Game scene!

        // FIXME: This is incorrect, we need to fetch the mapUrl from the adminService.
        // FIXME: This is incorrect, we need to fetch the mapUrl from the adminService.
        // FIXME: This is incorrect, we need to fetch the mapUrl from the adminService.
        // FIXME: This is incorrect, we need to fetch the mapUrl from the adminService.
        // FIXME: This is incorrect, we need to fetch the mapUrl from the adminService.
        // Then, we need to cache the call to the mapUrl to avoid too many calls (possibly setting up axios to use etags too!)
        const urlObject = new URL(this.url);
        let mapUrl = urlObject.pathname;
        const urlParsed = mapUrl.substring(1).split("/");
        // If the urlParsed is empty the url will be http://
        mapUrl = "http://" + urlParsed.splice(2, urlParsed.length - 1).join("/");
        // Error throw here and not catched !!!!
        const fetchedData = await axios.get(mapUrl);

        const checkMapFile = ITiledMap.safeParse(fetchedData.data);
        return checkMapFile.success ? checkMapFile.data : undefined;
    }