@fireemu/darwin-arm64 0.69.0 → 0.71.0

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.
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # @fireemu/darwin-arm64
2
2
 
3
3
  The [fireemu](https://www.npmjs.com/package/fireemu) daemon built for `darwin-arm64`
4
- (Rust target `aarch64-apple-darwin`), version 0.69.0.
4
+ (Rust target `aarch64-apple-darwin`), version 0.71.0.
5
5
 
6
6
  macOS 13 or newer on Apple silicon.
7
7
 
package/bin/fireemu CHANGED
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/bin/fireemu
3
- size: 38900032 bytes
4
- sha256: a72576b1028860d4f415659386dc9fabf20b9ea38b215ce14e3a747cd4206282
3
+ size: 38933120 bytes
4
+ sha256: 1f6ec39e9f59957a2bbc92c379ffc8f7b549d3b00e7a3fbf99a2c3ae56f443d7
@@ -114,14 +114,70 @@ export function createRuntimeClock({date = 'real', timers: timerPolicy = 'real',
114
114
  }
115
115
 
116
116
  function cancel(value) {
117
- const handle = value instanceof Timer ? value : handles.get(Number(value));
118
- if (!handle) return;
117
+ if (value instanceof Timer) {
118
+ value.cancelled = true;
119
+ queue.delete(value.id);
120
+ handles.delete(value.id);
121
+ return;
122
+ }
123
+ if (typeof value === 'object' && value !== null) {
124
+ native.clearTimeout(value);
125
+ return;
126
+ }
127
+ const handle = handles.get(Number(value));
128
+ if (!handle) {
129
+ native.clearTimeout(value);
130
+ return;
131
+ }
132
+ handle.cancelled = true;
133
+ queue.delete(handle.id);
134
+ handles.delete(handle.id);
135
+ }
136
+
137
+ function cancelInterval(value) {
138
+ if (value instanceof Timer) {
139
+ value.cancelled = true;
140
+ queue.delete(value.id);
141
+ handles.delete(value.id);
142
+ return;
143
+ }
144
+ if (typeof value === 'object' && value !== null) {
145
+ native.clearInterval(value);
146
+ return;
147
+ }
148
+ const handle = handles.get(Number(value));
149
+ if (!handle) {
150
+ native.clearInterval(value);
151
+ return;
152
+ }
119
153
  handle.cancelled = true;
120
154
  queue.delete(handle.id);
121
155
  handles.delete(handle.id);
122
156
  }
123
157
 
158
+ // Internal gRPC transport timers (BackoffTimeout, ResolvingCall deadlines, subchannel
159
+ // keepalive/cleanup) live inside `@grpc/grpc-js`. Freezing them under a non-following
160
+ // virtual clock deadlocks Admin SDK calls inside Functions triggers. Exempt only when
161
+ // the immediate caller frame outside `clock.mjs` belongs to `@grpc/grpc-js`.
162
+ function isTransportTimerCaller() {
163
+ const stack = new Error().stack;
164
+ if (typeof stack !== 'string') return false;
165
+ const lines = stack.split('\n');
166
+ for (let i = 1; i < lines.length; i++) {
167
+ const normalized = lines[i].replace(/\\/g, '/');
168
+ if (normalized.includes('/runner-node/clock.mjs')) continue;
169
+ return (
170
+ normalized.includes('node_modules/') &&
171
+ /(?:@grpc[+/]grpc-js|google-gax|@google-cloud[+/](?:firestore|storage)|gaxios|google-auth-library)\//.test(
172
+ normalized,
173
+ )
174
+ );
175
+ }
176
+ return false;
177
+ }
178
+
124
179
  function promiseTimeout(duration, value, config = {}) {
180
+ if (isTransportTimerCaller()) return nativePromises.setTimeout(duration, value, config);
125
181
  try { options(config); } catch (error) { return Promise.reject(error); }
126
182
  if (config.signal?.aborted) return Promise.reject(abortError(config.signal.reason));
127
183
  return new Promise((resolve, reject) => {
@@ -140,29 +196,32 @@ export function createRuntimeClock({date = 'real', timers: timerPolicy = 'real',
140
196
  });
141
197
  }
142
198
 
143
- async function* promiseInterval(duration, value, config = {}) {
144
- options(config);
145
- if (config.signal?.aborted) throw abortError(config.signal.reason);
146
- let count = 0;
147
- let wake;
148
- let aborted = false;
149
- const handle = schedule(() => { count++; wake?.(); }, duration, [], true);
150
- if (config.ref === false) handle.unref();
151
- const abort = () => { aborted = true; cancel(handle); wake?.(); };
152
- config.signal?.addEventListener('abort', abort, {once:true});
153
- try {
154
- while (!aborted) {
155
- if (count === 0) await new Promise(resolve => {wake = resolve;});
156
- wake = undefined;
157
- if (aborted) break;
158
- count--;
159
- yield value;
199
+ function promiseInterval(duration, value, config = {}) {
200
+ if (isTransportTimerCaller()) return nativePromises.setInterval(duration, value, config);
201
+ return (async function* () {
202
+ options(config);
203
+ if (config.signal?.aborted) throw abortError(config.signal.reason);
204
+ let count = 0;
205
+ let wake;
206
+ let aborted = false;
207
+ const handle = schedule(() => { count++; wake?.(); }, duration, [], true);
208
+ if (config.ref === false) handle.unref();
209
+ const abort = () => { aborted = true; cancel(handle); wake?.(); };
210
+ config.signal?.addEventListener('abort', abort, {once:true});
211
+ try {
212
+ while (!aborted) {
213
+ if (count === 0) await new Promise(resolve => {wake = resolve;});
214
+ wake = undefined;
215
+ if (aborted) break;
216
+ count--;
217
+ yield value;
218
+ }
219
+ throw abortError(config.signal.reason);
220
+ } finally {
221
+ cancel(handle);
222
+ config.signal?.removeEventListener('abort', abort);
160
223
  }
161
- throw abortError(config.signal.reason);
162
- } finally {
163
- cancel(handle);
164
- config.signal?.removeEventListener('abort', abort);
165
- }
224
+ })();
166
225
  }
167
226
 
168
227
  function now() {
@@ -199,9 +258,16 @@ export function createRuntimeClock({date = 'real', timers: timerPolicy = 'real',
199
258
  },
200
259
  });
201
260
  const virtual = {
202
- setTimeout: (callback, duration, ...args) => schedule(callback, duration, args, false),
203
- setInterval: (callback, duration, ...args) => schedule(callback, duration, args, true),
204
- clearTimeout: cancel, clearInterval: cancel,
261
+ setTimeout: (callback, duration, ...args) =>
262
+ isTransportTimerCaller()
263
+ ? native.setTimeout(callback, duration, ...args)
264
+ : schedule(callback, duration, args, false),
265
+ setInterval: (callback, duration, ...args) =>
266
+ isTransportTimerCaller()
267
+ ? native.setInterval(callback, duration, ...args)
268
+ : schedule(callback, duration, args, true),
269
+ clearTimeout: cancel,
270
+ clearInterval: cancelInterval,
205
271
  };
206
272
  Object.defineProperty(virtual.setTimeout, promisify.custom, {value:promiseTimeout});
207
273
 
@@ -518,13 +518,27 @@ function rejectAsyncOption(value, field) {
518
518
  return value;
519
519
  }
520
520
 
521
+ function isResetValue(value) {
522
+ if (value == null || typeof value !== "object") return false;
523
+ if (value[Symbol.for("firebase-functions:ResetValue:Tag")] === true) return true;
524
+ // firebase-functions 6.x ResetValue predates the symbol tag: `constructor.name === "ResetValue"`
525
+ // and `toJSON() === null`. Never read `.value` here so single-read Expression accessors stay intact.
526
+ if (
527
+ value.constructor?.name === "ResetValue" &&
528
+ typeof value.toJSON === "function" &&
529
+ value.toJSON() === null
530
+ ) {
531
+ return true;
532
+ }
533
+ return false;
534
+ }
535
+
521
536
  // SDK endpoint options keep Expression objects until the local runtime resolves
522
537
  // them. JSON/toString encode a deployment expression, not its runtime value.
523
538
  // Match the existing numeric-option `.value()` protocol, but never read its
524
539
  // accessor twice or coerce an unresolved value into false/true/default.
525
540
  function resolvedOption(value, field) {
526
- if (value == null) return undefined;
527
- if (value?.[Symbol.for("firebase-functions:ResetValue:Tag")] === true) return undefined;
541
+ if (value == null || isResetValue(value)) return undefined;
528
542
  if (typeof value === "object") {
529
543
  const evaluate = value.value;
530
544
  if (typeof evaluate === "function") {
@@ -573,7 +587,7 @@ function resolvedNonNegativeInteger(value, field) {
573
587
  // Do not stringify an Expression (that emits its deployment representation),
574
588
  // coerce malformed values, or retain a caller-owned map with a later toJSON.
575
589
  function triggerRecord(value, field) {
576
- if (value == null || value?.[Symbol.for("firebase-functions:ResetValue:Tag")] === true) {
590
+ if (value == null || isResetValue(value)) {
577
591
  return Object.create(null);
578
592
  }
579
593
  rejectAsyncOption(value, field);
@@ -690,10 +704,14 @@ function describeSchedule(base, value) {
690
704
  function platformOptions(ep) {
691
705
  if (!ep) return undefined;
692
706
  const options = {};
693
- const preserveExternalChanges =
707
+ const rawPreserveExternalChanges =
694
708
  ep.preserveExternalChanges ??
695
709
  (ep.platform === "gcfv2" ? discoveredGlobalOptions.preserveExternalChanges : undefined);
696
- if (preserveExternalChanges != null)
710
+ const preserveExternalChanges = resolvedOption(
711
+ rawPreserveExternalChanges,
712
+ "preserveExternalChanges",
713
+ );
714
+ if (preserveExternalChanges !== undefined)
697
715
  options.preserveExternalChanges = Boolean(preserveExternalChanges);
698
716
  const availableMemoryMb = resolvedNonNegativeInteger(ep.availableMemoryMb, "availableMemoryMb");
699
717
  if (availableMemoryMb !== undefined) options.availableMemoryMb = availableMemoryMb;
@@ -701,16 +719,26 @@ function platformOptions(ep) {
701
719
  if (minInstances !== undefined) options.minInstances = minInstances;
702
720
  const maxInstances = resolvedNonNegativeInteger(ep.maxInstances, "maxInstances");
703
721
  if (maxInstances !== undefined) options.maxInstances = maxInstances;
704
- if (ep.ingressSettings != null) options.ingressSettings = ep.ingressSettings;
722
+ const ingressSettings = resolvedOption(ep.ingressSettings, "ingressSettings");
723
+ if (ingressSettings !== undefined) options.ingressSettings = ingressSettings;
705
724
  if (ep.httpsTrigger?.invoker?.length) options.invoker = ep.httpsTrigger.invoker;
706
- if (ep.serviceAccountEmail != null) options.serviceAccountEmail = ep.serviceAccountEmail;
707
- if (ep.vpc?.connector != null) options.vpcConnector = ep.vpc.connector;
708
- if (ep.vpc?.egressSettings != null) options.vpcEgressSettings = ep.vpc.egressSettings;
709
- if (ep.labels && Object.keys(ep.labels).length > 0) options.labels = ep.labels;
725
+ const serviceAccountEmail = resolvedOption(ep.serviceAccountEmail, "serviceAccountEmail");
726
+ if (serviceAccountEmail !== undefined) options.serviceAccountEmail = serviceAccountEmail;
727
+ const vpc = resolvedOption(ep.vpc, "vpc");
728
+ if (vpc && typeof vpc === "object") {
729
+ const vpcConnector = resolvedOption(vpc.connector, "vpc.connector");
730
+ if (vpcConnector !== undefined) options.vpcConnector = vpcConnector;
731
+ const vpcEgressSettings = resolvedOption(vpc.egressSettings, "vpc.egressSettings");
732
+ if (vpcEgressSettings !== undefined) options.vpcEgressSettings = vpcEgressSettings;
733
+ }
734
+ if (ep.labels && !isResetValue(ep.labels) && Object.keys(ep.labels).length > 0) {
735
+ options.labels = ep.labels;
736
+ }
710
737
  if (ep.platform === "gcfv2") {
711
- if (ep.cpu != null) options.cpu = String(ep.cpu);
712
- if (Array.isArray(ep.vpc?.networkInterfaces))
713
- options.networkInterfaces = ep.vpc.networkInterfaces;
738
+ const cpu = resolvedOption(ep.cpu, "cpu");
739
+ if (cpu !== undefined) options.cpu = String(cpu);
740
+ if (vpc && typeof vpc === "object" && Array.isArray(vpc.networkInterfaces))
741
+ options.networkInterfaces = vpc.networkInterfaces;
714
742
  }
715
743
  if (Array.isArray(ep.secretEnvironmentVariables)) {
716
744
  options.secrets = ep.secretEnvironmentVariables.map((secret) => secret.key).filter(Boolean);
@@ -1438,8 +1466,21 @@ async function makeHttpServer(functions, manifest) {
1438
1466
  ? blockingFailure(error, HttpsErrors)
1439
1467
  : invocationFailure(error);
1440
1468
  try {
1441
- const diagnostic = blocking ? invocationFailure(error).diagnostic : failure.diagnostic;
1442
- log("error", `${spec.name}: ${diagnostic}`, undefined, spec.name);
1469
+ const expectedHttpsError =
1470
+ blocking &&
1471
+ Array.isArray(HttpsErrors) &&
1472
+ HttpsErrors.some((Ctor) => typeof Ctor === "function" && error instanceof Ctor) &&
1473
+ !(
1474
+ failure.canonicalName === "UNAVAILABLE" &&
1475
+ failure.status === 503 &&
1476
+ failure.message === "An unexpected error occurred."
1477
+ );
1478
+ if (expectedHttpsError) {
1479
+ log("warn", `${spec.name}: ${failure.canonicalName}: ${failure.message}`, undefined, spec.name);
1480
+ } else {
1481
+ const diagnostic = blocking ? invocationFailure(error).diagnostic : failure.diagnostic;
1482
+ log("error", `${spec.name}: ${diagnostic}`, undefined, spec.name);
1483
+ }
1443
1484
  } catch {
1444
1485
  // Diagnostics cannot suppress the already classified response.
1445
1486
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fireemu/darwin-arm64",
3
- "version": "0.69.0",
3
+ "version": "0.71.0",
4
4
  "description": "The fireemu daemon for darwin-arm64",
5
5
  "homepage": "https://fireemu.github.io/fireemu/",
6
6
  "repository": {