Commit Graph

231 Commits

Author SHA1 Message Date
SantiagoRR2004
9e270bebe4
Fix #11744; Importing mysql2 and pg when it is not required (#11747)
Some checks are pending
Node.js CI / build (18.x) (push) Waiting to run
2026-03-17 15:04:07 -07:00
TurboRx
550a9ad2a9
Fix visualize function Set case callback arguments (#11525) 2026-01-25 09:11:14 -05:00
Mia
e94ba6a848 Log PIDs for all subprocess crashes 2025-11-23 20:00:07 -06:00
Mia
f66eef5271 Fix typo 2025-11-23 19:44:44 -06:00
Mia
be4f2bd6ab Log Unix timestamp of crashes 2025-11-23 19:42:29 -06:00
Mia
8bae904193 SQL: Log process ID in errors for easier debugging 2025-11-23 19:39:22 -06:00
Slayer95
4b8c6a4d6d
Refactor startup (#11346)
Some checks failed
Node.js CI / build (18.x) (push) Has been cancelled
This minimizes side effects of import/require across the codebase,
and lets the caller be responsible of initializing child processeses,
as well as other async logic, such as restoring saved battles.
2025-10-17 19:37:47 -07:00
Guangcong Luo
e18740c70a Fix MySQL support in db library
Some checks are pending
Node.js CI / build (18.x) (push) Waiting to run
(Broken in a341d3c566)
2025-09-03 22:08:11 -07:00
Guangcong Luo
f770b255f3 Database: Revert syntax for multiline queries
As explicitly documented in `CONTRIBUTING.md`, we are against multiline
template strings. While I see the advantages in readability for the
multiline approach, I'd rather not send extraneous whitespace to the
database.
2025-08-05 22:11:43 -07:00
Mia
4a8341586a Database: Fix PG syntax error in update, remove unnecessary set method
Some checks are pending
Node.js CI / build (18.x) (push) Waiting to run
2025-08-05 16:38:28 -05:00
Mia
932350d503 Database: Remove more invalid limit statements
Some checks are pending
Node.js CI / build (18.x) (push) Waiting to run
2025-08-04 22:35:49 -05:00
Mia
a341d3c566 Database: Remove LIMIT clauses from primary key mutating methods
PG doesn't support LIMIT in these, and they don't need it anyway since primary keys should be unique.
2025-08-04 22:16:35 -05:00
Guangcong Luo
31a4289cc6
Refactor Teams plugin to use lib/database (#11109)
* Refactor Teams.save

Fixes a bug where passwords were changed every time a team was updated.

* Refactor Teams to use lib/database

* Add unit tests

(This found a bug which has also been fixed)

* Test more things

---------

Co-authored-by: Mia <49593536+mia-pi-git@users.noreply.github.com>
2025-08-04 21:51:42 -05:00
Sergio Garcia
005d98993f
Use URL API (#11316)
Some checks are pending
Node.js CI / build (18.x) (push) Waiting to run
* Fix typo

* Remove unnessecary file

* Use URL API

Clears this warning

```
(node:44968) [DEP0169] DeprecationWarning: `url.parse()`
  behavior is not standardized and prone to errors that have
  security implications. Use the WHATWG URL API instead. CVEs are
  not issued for `url.parse()` vulnerabilities.
```

---------

Co-authored-by: Mia <49593536+mia-pi-git@users.noreply.github.com>
Co-authored-by: HoeenHero <HoeenCoder@users.noreply.github.com>
2025-07-31 10:04:20 -05:00
Guangcong Luo
7a9e535e35
Vendor node-static (#11295)
Also includes a decent amount of refactoring to bring it in line with Showdown code standards.

---------

Co-authored-by: Slayer95 <ivojulca@hotmail.com>
2025-07-23 21:19:55 -07:00
Sergio Garcia
fc23103de1
Fix random typos (#11020)
Some checks are pending
Node.js CI / build (18.x) (push) Waiting to run
2025-04-13 23:59:36 -07:00
Guangcong Luo
4079fe7846 Database library: Support raw strings in SQL()
This is nearly never the right thing to do, but I guess some people
want raw power.
2025-04-12 17:13:47 -07:00
Slayer95
674defa1b1
Fix uncaught exceptions in net library (#10628)
Some checks are pending
Node.js CI / build (18.x) (push) Waiting to run
Added missing error event handler
2025-03-01 03:18:43 -08:00
Guangcong Luo
be518c5025 Suppress crash from probable race condition
Some checks failed
Node.js CI / build (18.x) (push) Waiting to run
Publish to npm / test (push) Has been cancelled
Publish to npm / get-version (push) Has been cancelled
Publish to npm / npm-publish (push) Has been cancelled
2025-02-26 22:28:46 -08:00
Guangcong Luo
73a04cdcba TypeScript: Enable noImplicitOverride
Some checks are pending
Publish to npm / test (push) Waiting to run
Publish to npm / get-version (push) Waiting to run
Publish to npm / npm-publish (push) Blocked by required conditions
Node.js CI / build (18.x) (push) Waiting to run
2025-02-26 14:38:32 -08:00
Guangcong Luo
62023bd299 Emit .d.ts types for NPM package
Some checks are pending
Publish to npm / test (push) Waiting to run
Publish to npm / get-version (push) Waiting to run
Publish to npm / npm-publish (push) Blocked by required conditions
Node.js CI / build (18.x) (push) Waiting to run
2025-02-26 02:44:08 -08:00
Guangcong Luo
e25bec3620 Remove some implicit conversions
boolean -> number and number -> string should be explicit. Probably
string -> number should be, too, but I'm not ready to turn on the lint
option yet.

This was supposed to be part of the big ESLint refactor but I forgot
to push it. <_<
2025-02-25 22:55:01 -08:00
Guangcong Luo
78439b4a02
Update to ESLint 9 (#10926)
ESLint has a whole new config format, so I figure it's a good time to
make the config system saner.

- First, we no longer have separate eslint-no-types configs. Lint
  performance shouldn't be enough of a problem to justify the
  relevant maintenance complexity.

- Second, our base config should work out-of-the-box now. `npx eslint`
  will work as expected, without any CLI flags. You should still use
  `npm run lint` which adds the `--cached` flag for performance.

- Third, whatever updates I did fixed style linting, which apparently
  has been bugged for quite some time, considering all the obvious
  mixed-tabs-and-spaces issues I found in the upgrade.

Also here are some changes to our style rules. In particular:

- Curly brackets (for objects etc) now have spaces inside them. Sorry
  for the huge change. ESLint doesn't support our old style, and most
  projects use Prettier style, so we might as well match them in this way.
  See https://github.com/eslint-stylistic/eslint-stylistic/issues/415

- String + number concatenation is no longer allowed. We now
  consistently use template strings for this.
2025-02-25 20:03:46 -08:00
Guangcong Luo
ec7332b498 Import Utils from lib/utils
Some checks are pending
Node.js CI / build (16.x) (push) Waiting to run
This mostly is just a step towards removing sim's dependency on Node's
stdlib.
2025-01-14 23:01:53 -08:00
Mia
d3e60b31f7
Sim: Use a CSPRNG (#10806)
* Sim: Use a CSPRNG

* Add test

* fix test prng

* move prng test to others

* fix slight hack

* tf?

* Fuck this

* fucking lol

* fix crap

* i'm going to kill someone

* i hate state

* fix test

* Good work genius

* typo

* Fix exportinputlog

* Refactor for inputlog backwards compatibility

This is a pretty major refactor which is mostly unrelated to the
feature, but it does make the code a lot simpler.

* Readability pass

* Readability (again)

* Remove sodium-native dependency

* Refactor to serialize seeds in hex strings

(Also removes the Buffer dependency from PRNG, and slightly improves
comments.)

* Apparently << is 32-bit signed

* Readability

---------

Co-authored-by: Guangcong Luo <guangcongluo@gmail.com>
2025-01-11 13:56:34 -06:00
Kris Johnson
89128dee97
Utils#Multiset: Redefine get to remove undefined return (#10329) 2024-06-06 17:16:59 -06:00
Mia
b048de52e2 Make the logs/ directory prefix configurable 2024-05-19 12:30:22 -05:00
Mia
bdc1ed2401 Chatlog: Add support for linecounts on the database 2024-05-18 03:14:57 -05:00
Mia
56c3b69fcd Utils: Ensure require cache clearing is exhaustive
Previously, this was limited by a depth check that always got hit, meaning it never fully properly cleaned out the module tree (most likely due to the fact the uncacheModuleTree call would loop around to the same module through recursion, meaning mod.children never got deleted, so it never stopped looping). This commit fixes that.
2024-04-22 15:41:54 -05:00
Guangcong Luo
517f34bee8
Fix outdated reference to .end() in Streams doc 2024-01-17 22:20:59 -08:00
Guangcong Luo
6f1a640b71
Improve Streams docs 2024-01-17 22:19:52 -08:00
Guangcong Luo
e22f49ef04 Fix REPL crashing on startup
The problem is that we were cleaning up old REPL sockets after
launching new ones. This moves the cleanup step to before Artemis
and Friends processes are launched.
2023-12-29 17:08:58 -06:00
urkerab
cd7aa49a16
Deep freeze an object's values directly (#10022) 2023-12-28 07:10:32 -08:00
Guangcong Luo
9cd64cba15 Freeze cached Sim objects
We're hunting ~~wabbits~~ validator bugs.

Honestly, this has been a long time coming, but Object.freeze perf
used to not be good enough for us to use it here. Here's hoping!
2023-12-07 01:26:51 -05:00
Guangcong Luo
6b42b4f6b2 Experimental direct replay uploading
We have a new replay server on a new engine using a new schema.

Everything's gone remarkably well, considering.
2023-12-02 11:07:08 -05:00
Mia
4b79ee1276 Net: Expose response data to consumers
Headers are useful for a couple of Net consumers (rate limit data, that sort of thing.)
2023-11-28 12:27:38 -06:00
Mia
effb8ed103 Utils: Explicitly traverse the module tree to ensure no references are held long-term 2023-11-20 22:19:49 -06:00
Mia
071d7e3c94 Process-manager: Don't hold unnecessary module references past their expiry 2023-11-20 21:28:42 -06:00
Mia
56a5175d00 Fix typo
Didn't mean to commit this.
2023-11-04 16:43:55 -05:00
Mia
d6c78db0dd SQL: Account for dist files in loading extensions 2023-11-04 16:41:47 -05:00
Mia
5f6d9029ac Prevent chat processes from nesting 2023-11-04 16:37:49 -05:00
Mia
0211066723
Add offline messaging (#8440) 2023-11-04 14:45:18 -05:00
Mia
f190b1c8a7
Add a chat plugin for storing teams remotely (#9513) 2023-09-24 11:22:26 -05:00
Mia
8caf1b7932 Process-manager: Respawn timed-out processes 2023-06-12 13:17:58 -05:00
Annika
0bc78dddf5 TypeScript 5! 2023-04-09 13:02:19 -07:00
Mia
35c7c62566 Fix Postgres config loading 2022-12-22 15:57:05 -06:00
Mia
b11177d530
Migrate to esbuild for compilation (#9203) 2022-12-22 15:19:29 -06:00
Mia
93a0a0f61c
Rooms: Only lockdown after restarts when battles crash (#9110) 2022-12-04 12:45:31 -05:00
Mia
8bdebea6e4 Fix eslint errors 2022-11-17 16:18:39 -06:00
Annika
9c5d654b89
Revert "Improved typing for utils.ts, and for iterating over base stats (#8919)" (#8938)
This reverts commit c589fb5a5a.
2022-10-16 18:27:25 -07:00