colyseus / colyseus-loadtest

Utility tool for load testing Colyseus.

Home Page:https://docs.colyseus.io/colyseus/tools/loadtest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Importing schemas from rooms causes ts-node to error

gioragutt opened this issue · comments

I want to use the testload as sort of a sanity test for my rooms.
I have a room that's practically a lobby where users say that they are ready.
I created a schema for that message, like this:

export class ChangeReadyMessage extends Schema {
  @type('boolean')
  ready!: boolean;
}

And then, in my load test script, I do something like this:

import { Room, Client } from 'colyseus.js';
import { ChangeReadyMessage } from '../src/rooms/SquadArrangementRoom';

export function onJoin(this: Room) {
  console.log(this.sessionId, 'joined.');

  setTimeout(() => {
    const ready = new ChangeReadyMessage();
    ready.ready = true;
    this.send(ready);
  }, 5000);
}

...

This results in the following error:

▶ npm run test-room -- loadtest/squad-arrangment-test.ts --room squad_arrangement --numClients 2

> capsule-royale-server@1.0.0 test-room /Users/giorag/Git/capsule-royale/Server
> colyseus-loadtest "loadtest/squad-arrangment-test.ts" "--room" "squad_arrangement" "--numClients" "2"

/Users/giorag/Git/capsule-royale/Server/node_modules/@colyseus/loadtest/node_modules/ts-node/src/index.ts:261
    return new TSError(diagnosticText, diagnosticCodes)
           ^
TSError: ⨯ Unable to compile TypeScript:
src/rooms/SquadArrangementRoom.ts(6,3): error TS1219: Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option in your 'tsconfig' or 'jsconfig' to remove this warning.
src/rooms/SquadArrangementRoom.ts(11,3): error TS1219: Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option in your 'tsconfig' or 'jsconfig' to remove this warning.
src/rooms/SquadArrangementRoom.ts(14,3): error TS1219: Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option in your 'tsconfig' or 'jsconfig' to remove this warning.
src/rooms/SquadArrangementRoom.ts(19,3): error TS1219: Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option in your 'tsconfig' or 'jsconfig' to remove this warning.
src/rooms/SquadArrangementRoom.ts(22,3): error TS1219: Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option in your 'tsconfig' or 'jsconfig' to remove this warning.

    at createTSError (/Users/giorag/Git/capsule-royale/Server/node_modules/@colyseus/loadtest/node_modules/ts-node/src/index.ts:261:12)
    at getOutput (/Users/giorag/Git/capsule-royale/Server/node_modules/@colyseus/loadtest/node_modules/ts-node/src/index.ts:367:40)
    at Object.compile (/Users/giorag/Git/capsule-royale/Server/node_modules/@colyseus/loadtest/node_modules/ts-node/src/index.ts:558:11)
    at Module.m._compile (/Users/giorag/Git/capsule-royale/Server/node_modules/@colyseus/loadtest/node_modules/ts-node/src/index.ts:439:43)
    at Module._extensions..js (internal/modules/cjs/loader.js:1171:10)
    at Object.require.extensions.<computed> [as .ts] (/Users/giorag/Git/capsule-royale/Server/node_modules/@colyseus/loadtest/node_modules/ts-node/src/index.ts:442:12)
    at Module.load (internal/modules/cjs/loader.js:1000:32)
    at Function.Module._load (internal/modules/cjs/loader.js:899:14)
    at Module.require (internal/modules/cjs/loader.js:1040:19)
    at require (internal/modules/cjs/helpers.js:72:18)

So I can assume that it's running ts-node from within node_modules, where it doesn't have a tsconfig which has (at least) decorators enabled.

Any way we can point the inner ts-node to use my project's tsconfig?

As a workaround for this, "experimentalDecorators" has been enabled on this project's tsconfig.json