@rocket.chat/houston 2.1.8 → 2.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -43,6 +43,7 @@ exports.rcServicesIn = rcServicesIn;
43
43
  exports.loadtestTarget = loadtestTarget;
44
44
  exports.short = short;
45
45
  exports.loginSeedUsers = loginSeedUsers;
46
+ exports.sessionLimitWarning = sessionLimitWarning;
46
47
  exports.requireComposeForPerf = requireComposeForPerf;
47
48
  exports.newLoadRun = newLoadRun;
48
49
  exports.putEverythingBack = putEverythingBack;
@@ -228,6 +229,24 @@ async function loginSeedUsers(rootUrl, count) {
228
229
  }
229
230
  return users;
230
231
  }
232
+ /**
233
+ * The warning for `journey` past 50 VUs per user, or null.
234
+ *
235
+ * Each journey iteration logs its VU in afresh (as the VU's seeded user, or the admin) and
236
+ * uses that session to its last step. Rocket.Chat keeps a user's newest 50 sessions and
237
+ * deletes the rest, so past 50 VUs per user it deletes sessions still in use, and their
238
+ * later steps fail with 4xx that are not the server's.
239
+ */
240
+ function sessionLimitWarning(scenario, vus, users) {
241
+ const most = 50 * Math.max(1, users);
242
+ if (scenario !== 'journey' || vus <= most)
243
+ return null;
244
+ const who = users > 0 ? `${String(users)} seeded user${users === 1 ? '' : 's'}` : 'the admin';
245
+ return (`journey at ${String(vus)} VUs is more than ${String(most)}, 50 per user for ${who}: ` +
246
+ `Rocket.Chat keeps 50 sessions per user and deletes the older ones while they are ` +
247
+ `still in use, so some steps fail with 4xx that are not the server's. Use fewer VUs, ` +
248
+ `or seed more users (houston seed --profile standard makes 20) and use them all`);
249
+ }
231
250
  /**
232
251
  * Refuse a load test or capacity search on a Kubernetes workspace, and say why.
233
252
  *
@@ -369,7 +388,9 @@ async function armAndRun({ auth, cli = null, deps, emit, m, perService, rcServic
369
388
  catch (exc) {
370
389
  // `constrain.apply` signals its own failures with a plain Error, and those are what
371
390
  // this answers; nothing else is expected from it, so wrapping every failure is no
372
- // broader a net than the one intended.
391
+ // broader a net than the one intended. A Ctrl-C is not one of them.
392
+ if (exc instanceof exec_1.Interrupted)
393
+ throw exc;
373
394
  throw constrainFailure(cli, exc);
374
395
  }
375
396
  // NOTED WITH THE PRIOR VALUES, so a killed run can be undone exactly rather than
@@ -630,41 +651,59 @@ async function runLoadtest(req, emit = events_1.nullEmit, deps = exports.DEFAULT
630
651
  }
631
652
  async function runPreparedLoadtest(req, prepared, emit = events_1.nullEmit, deps = exports.DEFAULT_DEPS, cli = null) {
632
653
  const { auth, m, perService, rcServices, rules, target, token, users } = prepared;
633
- const run = newLoadRun();
634
- try {
635
- await armAndRun({
636
- auth,
637
- cli,
638
- deps,
639
- emit,
640
- m,
641
- perService,
642
- rcServices,
643
- req,
644
- run,
645
- target,
646
- token,
647
- users,
648
- });
649
- }
650
- catch (exc) {
651
- // The ReproError taxonomy passes through and anything else is converted; every
652
- // failure `armAndRun` can raise on its own is a bad-input-or-engine one, and the
653
- // deliberate refusals above keep their own types.
654
- if (exc instanceof errors_1.ReproError)
655
- throw exc;
654
+ const shape = req.spike ?? req.ramp ?? '';
655
+ const peak = shape !== '' ? Math.max(...shape.split(':').map(Number)) : req.vus;
656
+ const words = sessionLimitWarning(req.scenario, peak, users.length);
657
+ if (words !== null) {
656
658
  if (cli === null)
657
- throw new errors_1.DockerError((0, errors_1.errorText)(exc));
658
- // The CLI's plain error: k6's unreadable or missing summary is REPRO_ERROR, exit 1. A
659
- // request that failed is a transport failure, which is not converted, so it goes on to
660
- // the contract's last line as it is.
661
- if (exc instanceof Error && exc.name === 'RequestFailed')
662
- throw exc;
663
- throw new errors_1.ReproError((0, errors_1.errorText)(exc));
664
- }
665
- finally {
666
- await putEverythingBack({ auth, cli, deps, emit, m, run });
659
+ (0, events_1.warn)(emit, words, { phase: 'k6' });
660
+ else
661
+ cli.warn(` ⚠ ${words}`);
667
662
  }
663
+ const run = newLoadRun();
664
+ // UNWOUND by a Ctrl-C: the wait on k6 raises Interrupted and the restore runs as cleanup,
665
+ // so what the run changed goes back as it does when the run fails. Without the unwind, a
666
+ // Ctrl-C ended the process with nothing put back.
667
+ await (0, exec_1.unwindsOnInterrupt)(async () => {
668
+ try {
669
+ await armAndRun({
670
+ auth,
671
+ cli,
672
+ deps,
673
+ emit,
674
+ m,
675
+ perService,
676
+ rcServices,
677
+ req,
678
+ run,
679
+ target,
680
+ token,
681
+ users,
682
+ });
683
+ }
684
+ catch (exc) {
685
+ if (exc instanceof exec_1.Interrupted)
686
+ throw exc;
687
+ // The ReproError taxonomy passes through and anything else is converted; every
688
+ // failure `armAndRun` can raise on its own is a bad-input-or-engine one, and the
689
+ // deliberate refusals above keep their own types.
690
+ if (exc instanceof errors_1.ReproError)
691
+ throw exc;
692
+ if (cli === null)
693
+ throw new errors_1.DockerError((0, errors_1.errorText)(exc));
694
+ // The CLI's plain error: k6's unreadable or missing summary is REPRO_ERROR, exit 1. A
695
+ // request that failed is a transport failure, which is not converted, so it goes on to
696
+ // the contract's last line as it is.
697
+ if (exc instanceof Error && exc.name === 'RequestFailed')
698
+ throw exc;
699
+ throw new errors_1.ReproError((0, errors_1.errorText)(exc));
700
+ }
701
+ finally {
702
+ await (0, exec_1.cleanup)(async () => {
703
+ await putEverythingBack({ auth, cli, deps, emit, m, run });
704
+ });
705
+ }
706
+ });
668
707
  const verdict = await loadtestVerdict({ cli, deps, emit, m, req, rules, run });
669
708
  return { run, verdict };
670
709
  }
@@ -832,6 +871,8 @@ async function searchForCapacity({ auth, cli = null, deps, emit, m, perService,
832
871
  search.applied = await deps.constrain.apply(m.name, perService);
833
872
  }
834
873
  catch (exc) {
874
+ if (exc instanceof exec_1.Interrupted)
875
+ throw exc;
835
876
  throw constrainFailure(cli, exc);
836
877
  }
837
878
  // NOTED WITH THE PRIOR VALUES, so a killed run can be undone exactly rather than
@@ -919,7 +960,17 @@ async function runCapacity(req, emit = events_1.nullEmit, deps = exports.DEFAULT
919
960
  async function runPreparedCapacity(req, prepared, emit = events_1.nullEmit, deps = exports.DEFAULT_DEPS, cli = null) {
920
961
  const { auth, m, perService, rcServices, rules, target, token, users } = prepared;
921
962
  const search = newCapacitySearch();
963
+ let warned = false;
922
964
  const runStep = async (n, tag = '') => {
965
+ // Said once, at the first step that crosses it: the rows from there on are suspect.
966
+ const words = warned ? null : sessionLimitWarning(req.scenario, n, users.length);
967
+ if (words !== null) {
968
+ warned = true;
969
+ if (cli === null)
970
+ (0, events_1.warn)(emit, words, { phase: 'k6' });
971
+ else
972
+ cli.warn(` ⚠ ${words}`);
973
+ }
923
974
  const sampler = new deps.rcmetrics.RCMetricsSampler(m.name, rcServices).start();
924
975
  let s;
925
976
  let rcm;
@@ -974,22 +1025,27 @@ async function runPreparedCapacity(req, prepared, emit = events_1.nullEmit, deps
974
1025
  }
975
1026
  return row;
976
1027
  };
977
- try {
978
- await searchForCapacity({
979
- auth,
980
- cli,
981
- deps,
982
- emit,
983
- m,
984
- perService,
985
- req,
986
- runStep,
987
- search,
988
- });
989
- }
990
- finally {
991
- await putTheWorkspaceBack({ auth, cli, deps, emit, m, search });
992
- }
1028
+ // UNWOUND by a Ctrl-C, as `runPreparedLoadtest` is.
1029
+ await (0, exec_1.unwindsOnInterrupt)(async () => {
1030
+ try {
1031
+ await searchForCapacity({
1032
+ auth,
1033
+ cli,
1034
+ deps,
1035
+ emit,
1036
+ m,
1037
+ perService,
1038
+ req,
1039
+ runStep,
1040
+ search,
1041
+ });
1042
+ }
1043
+ finally {
1044
+ await (0, exec_1.cleanup)(async () => {
1045
+ await putTheWorkspaceBack({ auth, cli, deps, emit, m, search });
1046
+ });
1047
+ }
1048
+ });
993
1049
  const { result, why } = cli === null ? capacityVerdict(emit, req, search) : capacityWords(req, search);
994
1050
  return { search, result, why };
995
1051
  }
@@ -192,7 +192,7 @@ function providerRoots(meta) {
192
192
  async function samlProvidersReady(meta, auth, roots, timeoutMs = 3000) {
193
193
  const ready = await Promise.all(roots.map(async (root) => await rcapi.samlProviderReady(root, {
194
194
  auth,
195
- publicUrl: meta.publicUrl || meta.rootUrl,
195
+ publicUrl: (0, record_1.externalUrl)(meta),
196
196
  timeoutMs,
197
197
  })));
198
198
  return ready.every((ok) => ok);
@@ -251,7 +251,7 @@ async function registerSamlProvider(meta, auth, roots, enable, emit, sleep) {
251
251
  }
252
252
  for (let attempt = 0; attempt < 12; attempt += 1) {
253
253
  const states = await Promise.all(roots.map(async (root) => await rcapi.samlProviderState(root, provider, {
254
- publicUrl: meta.publicUrl || meta.rootUrl,
254
+ publicUrl: (0, record_1.externalUrl)(meta),
255
255
  })));
256
256
  const all = states.every((state) => state === 'unloaded');
257
257
  if (all && stable) {
@@ -392,8 +392,9 @@ async function oauthProvidersReady(roots, provider, auth, timeoutMs) {
392
392
  /** Configure the disabled custom provider before enabling its debounced RC loader. */
393
393
  async function prCreateOauthProvider(meta, auth, action, emit, sleep) {
394
394
  const name = String(required(action, 'name'));
395
- if (!(await rcapi.addOauthService(meta.rootUrl, auth, (0, record_1.adminPass)(meta), name))) {
396
- (0, events_1.warn)(emit, 'could not create the OAuth provider', { phase: 'post_ready' });
395
+ const refused = await rcapi.addOauthService(meta.rootUrl, auth, (0, record_1.adminPass)(meta), name);
396
+ if (refused !== null) {
397
+ (0, events_1.warn)(emit, `could not create the OAuth provider: ${refused}`, { phase: 'post_ready' });
397
398
  return false;
398
399
  }
399
400
  const settings = { ...required(action, 'settings') };
@@ -934,14 +935,15 @@ function resetActions() {
934
935
  * `null` when there was no admin session to run them with -- nothing ran, which is a
935
936
  * different answer from "they all succeeded".
936
937
  */
937
- async function runPostReady(meta, auth, emit, { sleep = realSleep } = {}) {
938
+ async function runPostReady(meta, auth, emit, { sleep = realSleep, licenseGate = null } = {}) {
938
939
  const extra = bagOf(meta.extra);
939
940
  const raw = extra.post_ready;
940
941
  const actions = Array.isArray(raw) ? raw : [];
941
942
  if (auth === null || auth === undefined) {
942
943
  if (actions.length > 0) {
943
944
  (0, events_1.warn)(emit, 'preset self-config skipped - could not log in as admin; ' +
944
- `re-run once reachable: houston ready --name ${meta.name}`, { phase: 'post_ready' });
945
+ `re-run once reachable: houston ready --name ${meta.name} ` +
946
+ '(in the GUI: take it down, then bring it up)', { phase: 'post_ready' });
945
947
  }
946
948
  return null;
947
949
  }
@@ -962,8 +964,13 @@ async function runPostReady(meta, auth, emit, { sleep = realSleep } = {}) {
962
964
  (0, events_1.warn)(emit, `the workspace is RUNNING but its ${(0, format_1.quotedText)(meta.preset)} ` +
963
965
  `${(0, composite_1.namesOf)(meta.preset).length > 1 ? 'presets are' : 'preset is'} only ` +
964
966
  `partly configured — these did not complete: ${failed.join(', ')}`, { phase: 'post_ready' });
965
- (0, events_1.warn)(emit, ` Rocket.Chat itself is fine. Re-run the preset's ` +
966
- `self-configuration with: houston ready --name ${meta.name}`, { phase: 'post_ready' });
967
+ // Re-running is no use while Rocket.Chat 9 refuses the sign-in it sets up: say what is.
968
+ (0, events_1.warn)(emit, (licenseGate === null
969
+ ? ` Rocket.Chat itself is fine. Re-run the preset's self-configuration with: `
970
+ : ` Rocket.Chat 9 refuses ${licenseGate.kinds} sign-in without a license carrying ` +
971
+ `${licenseGate.modules}, so this cannot finish until one is added. Add it, then ` +
972
+ `re-run the preset's self-configuration with: `) +
973
+ `houston ready --name ${meta.name} (in the GUI: take it down, then bring it up)`, { phase: 'post_ready' });
967
974
  }
968
975
  return failed;
969
976
  }
@@ -55,7 +55,7 @@ exports.createIncomingWebhook = createIncomingWebhook;
55
55
  exports.createOutgoingWebhook = createOutgoingWebhook;
56
56
  exports.updateOutgoingUrls = updateOutgoingUrls;
57
57
  exports.getSetting = getSetting;
58
- exports.licenseValid = licenseValid;
58
+ exports.licenseInfo = licenseInfo;
59
59
  exports.settingIds = settingIds;
60
60
  exports.setSetting = setSetting;
61
61
  exports.samlProviderState = samlProviderState;
@@ -796,23 +796,33 @@ async function getSetting(rootUrl, auth, password, settingId, { timeoutMs = 1500
796
796
  if (resp.status === 200 && parsed.success === true)
797
797
  return parsed.value;
798
798
  }
799
- catch {
800
- // Unreachable or unparseable: the caller gets null, which is "unavailable".
799
+ catch (error) {
800
+ // Unreachable or unparseable: the caller gets null, which is "unavailable". A Ctrl-C is
801
+ // neither, and the run it ends unwinds through here.
802
+ if (error instanceof exec_1.Interrupted)
803
+ throw error;
801
804
  }
802
805
  return null;
803
806
  }
804
807
  /**
805
- * Whether Rocket.Chat ACCEPTED the license it holds: true, false, or null when it could not
806
- * be asked (not serving, or a release whose `licenses.info` does not say).
808
+ * Whether Rocket.Chat ACCEPTED the license it holds, and the modules that license turns on
809
+ * (`oauth-enterprise`...; null when the release does not list them). Null when it could not be
810
+ * asked (not serving, or a release whose `licenses.info` does not say).
807
811
  */
808
- async function licenseValid(rootUrl, auth, { timeoutMs = 15000 } = {}) {
812
+ async function licenseInfo(rootUrl, auth, { timeoutMs = 15000 } = {}) {
809
813
  try {
810
814
  const resp = await get(`${trimEnd(rootUrl)}/api/v1/licenses.info`, {
811
815
  headers: authHeaders(auth),
812
816
  timeoutMs,
813
817
  });
814
- const valid = map(body(resp).license).hasValidLicense;
815
- return resp.status === 200 && typeof valid === 'boolean' ? valid : null;
818
+ const license = map(body(resp).license);
819
+ const valid = license.hasValidLicense;
820
+ if (resp.status !== 200 || typeof valid !== 'boolean')
821
+ return null;
822
+ const modules = Array.isArray(license.activeModules)
823
+ ? license.activeModules.filter((m) => typeof m === 'string')
824
+ : null;
825
+ return { valid, modules };
816
826
  }
817
827
  catch {
818
828
  return null;
@@ -863,7 +873,9 @@ async function setSetting(rootUrl, auth, password, settingId, value, { timeoutMs
863
873
  });
864
874
  return resp.status === 200 && body(resp).success === true;
865
875
  }
866
- catch {
876
+ catch (error) {
877
+ if (error instanceof exec_1.Interrupted)
878
+ throw error;
867
879
  return false;
868
880
  }
869
881
  }
@@ -972,14 +984,45 @@ async function methodCall(rootUrl, auth, password, method, params, { timeoutMs =
972
984
  }
973
985
  }
974
986
  /**
975
- * Create a Custom OAuth provider via Rocket.Chat's `addOAuthService` method.
987
+ * Create a Custom OAuth provider: null once created, else why not, in Rocket.Chat's words
988
+ * where it gave some.
976
989
  *
977
990
  * A custom provider's `Accounts_OAuth_Custom-<name>-*` settings do not exist until it is
978
991
  * created, so OVERWRITE_SETTING env cannot configure it -- this creates the provider (and
979
- * its settings) so they can then be set via the API.
992
+ * its settings) so they can then be set via the API. Through `settings.addCustomOAuth`,
993
+ * which every release from 3.8 has; 9.0 removed the `addOAuthService` method it used to go
994
+ * through, and refuses both without a licence carrying `oauth-enterprise`.
980
995
  */
981
996
  async function addOauthService(rootUrl, auth, password, name, { timeoutMs = 15000 } = {}) {
982
- return await methodCall(rootUrl, auth, password, 'addOAuthService', [name], { timeoutMs });
997
+ const headers = {
998
+ ...authHeaders(auth),
999
+ 'Content-Type': 'application/json',
1000
+ ...(await password2faHeaders(password)),
1001
+ };
1002
+ let resp;
1003
+ try {
1004
+ resp = await post(`${trimEnd(rootUrl)}/api/v1/settings.addCustomOAuth`, {
1005
+ headers,
1006
+ json: { name },
1007
+ timeoutMs,
1008
+ });
1009
+ }
1010
+ catch (error) {
1011
+ return `no answer from Rocket.Chat: ${error.message}`;
1012
+ }
1013
+ if (resp.status === 404) {
1014
+ // Before 3.8 the method is the only way.
1015
+ const made = await methodCall(rootUrl, auth, password, 'addOAuthService', [name], {
1016
+ timeoutMs,
1017
+ });
1018
+ return made ? null : 'Rocket.Chat refused the addOAuthService method';
1019
+ }
1020
+ const answer = body(resp);
1021
+ if (resp.status === 200 && answer.success === true)
1022
+ return null;
1023
+ return typeof answer.error === 'string' && answer.error !== ''
1024
+ ? answer.error
1025
+ : `HTTP ${resp.status}`;
983
1026
  }
984
1027
  /** Create a verified user (idempotent-ish: an existing username just fails). */
985
1028
  async function createUser(rootUrl, auth, password, username, { timeoutMs = 15000 } = {}) {
@@ -1026,24 +1069,32 @@ async function addLivechatAgent(rootUrl, auth, password, username, { timeoutMs =
1026
1069
  return false;
1027
1070
  }
1028
1071
  }
1029
- /** Give user `id` a voice call extension; false when Rocket.Chat refuses (Voice unlicensed). */
1072
+ /**
1073
+ * Give user `id` a voice call extension; false when Rocket.Chat refuses (Voice unlicensed).
1074
+ * 9.0 renamed the field `freeSwitchExtension` to `sipExtension`, and every release from 8.0
1075
+ * refuses a field it does not know, so the old name is sent only after the new one is refused.
1076
+ */
1030
1077
  async function setVoiceExtension(rootUrl, auth, password, id, extension, { timeoutMs = 15000 } = {}) {
1031
1078
  const headers = {
1032
1079
  ...authHeaders(auth),
1033
1080
  'Content-Type': 'application/json',
1034
1081
  ...(await password2faHeaders(password)),
1035
1082
  };
1036
- try {
1037
- const resp = await post(`${trimEnd(rootUrl)}/api/v1/users.update`, {
1038
- headers,
1039
- json: { userId: id, data: { freeSwitchExtension: extension } },
1040
- timeoutMs,
1041
- });
1042
- return resp.status === 200 && body(resp).success === true;
1043
- }
1044
- catch {
1045
- return false;
1083
+ for (const field of ['sipExtension', 'freeSwitchExtension']) {
1084
+ try {
1085
+ const resp = await post(`${trimEnd(rootUrl)}/api/v1/users.update`, {
1086
+ headers,
1087
+ json: { userId: id, data: { [field]: extension } },
1088
+ timeoutMs,
1089
+ });
1090
+ if (resp.status === 200 && body(resp).success === true)
1091
+ return true;
1092
+ }
1093
+ catch {
1094
+ return false;
1095
+ }
1046
1096
  }
1097
+ return false;
1047
1098
  }
1048
1099
  /** Resolve a username to its `_id` via users.info, or null. */
1049
1100
  async function getUserId(rootUrl, auth, username, { timeoutMs = 15000 } = {}) {
@@ -87,6 +87,7 @@ const versions_1 = require("../lib/versions");
87
87
  const audit = __importStar(require("./audit"));
88
88
  const backup = __importStar(require("./backup"));
89
89
  const naming_1 = require("./lifecycle/naming");
90
+ const notes_1 = require("./lifecycle/notes");
90
91
  const ownership_1 = require("./lifecycle/ownership");
91
92
  const preconditions_1 = require("./lifecycle/preconditions");
92
93
  const types_1 = require("./lifecycle/types");
@@ -304,6 +305,14 @@ async function plan(name, toVersion, { offline = false, fetcher } = {}) {
304
305
  warnings.push('this workspace terminates TLS; its certificate and Traefik configuration are ' +
305
306
  'left exactly as they are');
306
307
  }
308
+ // What Rocket.Chat 9 will ask of this sign-in (a licence, HTTPS for OAuth), said before the
309
+ // upgrade reproduces it rather than found at the login page: the notes say it from then on.
310
+ if ((0, notes_1.signInGroup)(meta).length === 0) {
311
+ const after = (0, notes_1.signInGroup)({ ...meta, rcVersion: resolved.rcVersion });
312
+ for (const line of after.flatMap((group) => group.body)) {
313
+ warnings.push(`after the upgrade to ${resolved.rcVersion}: ${line}`);
314
+ }
315
+ }
307
316
  return {
308
317
  name: meta.name,
309
318
  from_version: meta.rcVersion,
@@ -57,8 +57,10 @@ function samlClient() {
57
57
  clientId: exports.SAML_CLIENT,
58
58
  protocol: 'saml',
59
59
  enabled: true,
60
- // Trailing wildcard: matches whatever host port houston assigns to RC.
61
- redirectUris: ['http://localhost*'],
60
+ // WHERE KEYCLOAK MAY POST THE ASSERTION BACK: Rocket.Chat's `<Site_Url>/_saml/validate/…`.
61
+ // `http://localhost*` alone refused (400) every workspace whose Site_Url is another name --
62
+ // `--root-url`, a proxy, a tunnel -- on every version; same reasoning as the OIDC client.
63
+ redirectUris: ['http://*', 'https://*'],
62
64
  frontchannelLogout: true,
63
65
  attributes: {
64
66
  'saml.assertion.signature': 'true', // sign the assertion
@@ -22,6 +22,7 @@ const format_1 = require("../lib/format");
22
22
  const host_1 = require("../core/runner/host");
23
23
  const engine_1 = require("../core/runner/engine");
24
24
  const docker_cli_1 = require("../seams/docker-cli");
25
+ const exec_1 = require("../seams/exec");
25
26
  const MEM_RE = /^\d+(\.\d+)?(g|gb|m|mb)$/u;
26
27
  /**
27
28
  * `'rc=2cpu/2g,mongo=1cpu'` -> `{rc: {cpus: 2.0, mem: '2g'}, …}`.
@@ -218,7 +219,9 @@ async function apply(name, perService) {
218
219
  }
219
220
  }
220
221
  catch (error) {
221
- await restore(applied);
222
+ // As cleanup, so a Ctrl-C that raised in here does not end the process before the caps
223
+ // already set go back: nothing has noted them yet, so nothing else would.
224
+ await (0, exec_1.cleanup)(async () => await restore(applied));
222
225
  throw error;
223
226
  }
224
227
  return applied;
@@ -12,6 +12,7 @@ exports.parseProm = parseProm;
12
12
  * with RC by definition) -- no extra images, no Grafana.
13
13
  */
14
14
  const engine_1 = require("../core/runner/engine");
15
+ const exec_1 = require("../seams/exec");
15
16
  /**
16
17
  * Unlabeled gauges worth tracking, verified against a live RC `/metrics` dump and the
17
18
  * official dashboard.
@@ -120,7 +121,19 @@ class RCMetricsSampler {
120
121
  return this;
121
122
  }
122
123
  async run() {
123
- while (!this.stopping) {
124
+ try {
125
+ await this.sample();
126
+ }
127
+ catch (error) {
128
+ // A Ctrl-C took the sample in flight: the run is unwinding, and `stop()` reports what
129
+ // was sampled before it.
130
+ if (!(error instanceof exec_1.Interrupted))
131
+ throw error;
132
+ }
133
+ }
134
+ async sample() {
135
+ // Not after a Ctrl-C: a sample started then ends the process before the run's restore.
136
+ while (!this.stopping && !(0, exec_1.interruptRaised)()) {
124
137
  for (const svc of this.services) {
125
138
  // The seam takes MILLISECONDS; `SAMPLE_TIMEOUT_S` is seconds.
126
139
  const [rc, text] = await (0, engine_1.composeExecCapture)(this.name, svc, ['node', '-e', exports.FETCH_JS], SAMPLE_TIMEOUT_S * 1000);
@@ -22,6 +22,7 @@ exports.parseMem = parseMem;
22
22
  */
23
23
  const engine_1 = require("../core/runner/engine");
24
24
  const queries_1 = require("../core/runner/queries");
25
+ const exec_1 = require("../seams/exec");
25
26
  const MEM_UNITS = Object.freeze({
26
27
  b: 1,
27
28
  kb: 1000,
@@ -77,6 +78,16 @@ class ResourceMonitor {
77
78
  return this;
78
79
  }
79
80
  async loop() {
81
+ try {
82
+ await this.sample();
83
+ }
84
+ catch (error) {
85
+ // As `RCMetricsSampler.run`: a Ctrl-C took the sample in flight, and the run unwinds.
86
+ if (!(error instanceof exec_1.Interrupted))
87
+ throw error;
88
+ }
89
+ }
90
+ async sample() {
80
91
  // ON A LATER TURN, so the first read runs after `start()` has returned rather than in
81
92
  // `start()` itself. Called straight through, the first `docker compose ps -q` was
82
93
  // spawned before `start()` returned -- ahead of the k6 run it is there to watch, on
@@ -87,7 +98,8 @@ class ResourceMonitor {
87
98
  setImmediate(resolve);
88
99
  });
89
100
  let ids = await (0, engine_1.containerIds)(this.reproName);
90
- while (!this.stopping) {
101
+ // Not after a Ctrl-C, as `RCMetricsSampler.sample`.
102
+ while (!this.stopping && !(0, exec_1.interruptRaised)()) {
91
103
  // A workspace whose containers were not up yet at the first poll gets another
92
104
  // chance, which is what makes wrapping a create work.
93
105
  if (ids.length === 0)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rocket.chat/houston",
3
- "version": "2.1.8",
3
+ "version": "2.1.9",
4
4
  "description": "Reproduce a customer's Rocket.Chat issue on their exact version, in minutes.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -76,5 +76,8 @@
76
76
  "commander": "~14.0.2",
77
77
  "fastify": "5.12.6",
78
78
  "yaml": "^2.9.1"
79
+ },
80
+ "resolutions": {
81
+ "minimatch": "^11.0.1"
79
82
  }
80
83
  }