@dasasian/firebase-structured-logger 0.4.0-beta.0 → 0.5.0-beta.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
@@ -163,16 +163,34 @@ logger.addBreadcrumb(type, name, data?)
163
163
  ## Functions API
164
164
 
165
165
  ```ts
166
- import { initLogger, initRequestLogger, logError, logInfo } from '@dasasian/firebase-structured-logger/functions'
166
+ import { initLogger, withLogging, logError, logInfo } from '@dasasian/firebase-structured-logger/functions'
167
167
 
168
168
  initLogger({ appId: 'my-app' }) // at module load
169
169
 
170
- export const myFunction = onCall(async (request) => {
171
- initRequestLogger(request, { functionName: 'myFunction' }) // seeds userId + functionName
172
- logInfo('started')
173
- })
170
+ export const myFunction = onCall(
171
+ withLogging({ functionName: 'myFunction' }, async (request) => {
172
+ logInfo('started') // carries userId + functionName automatically
173
+ }),
174
+ )
175
+ ```
176
+
177
+ `withLogging` binds the request's labels for the duration of the handler and unwinds
178
+ afterwards, so one request's `userId` can never appear on another's logs. Labels that
179
+ depend on the request are computed per call:
180
+
181
+ ```ts
182
+ withLogging(
183
+ (request) => ({ functionName: 'myFunction', labels: { orgId: request.data.orgId } }),
184
+ async (request) => { /* … */ },
185
+ )
174
186
  ```
175
187
 
188
+ > **`initRequestLogger` is deprecated and removed in 0.6.0.** It binds the scope with
189
+ > `enterWith()`, which is never unwound — the labels outlive the request, so a later
190
+ > handler that does *not* call it (a scheduled function, a Firestore trigger, or anything
191
+ > relying on `getLogger()`'s anonymous fallback) inherits whichever user last touched the
192
+ > warm instance. Handlers that all call it are unaffected; the hazard is the ones that don't.
193
+
176
194
  Backend log methods also accept an optional `attachments` (`Record<string, string | Buffer>`).
177
195
 
178
196
  ## CLI (`fsl`)
@@ -185,7 +203,8 @@ npx fsl upload-sourcemaps [--bucket=<name>] [--functions=<path>] [--embed-source
185
203
  npx fsl install-skills
186
204
  ```
187
205
 
188
- > The `fsl pack` / `pack-restore` commands exist only for consuming this package via a local `file:` dependency (they vendor a tgz so `firebase deploy` can bundle it). When you install from npm — as above — you don't need them.
206
+ > To try an unreleased change in a real deployment, publish a prerelease and install it:
207
+ > `npm publish --tag beta`, then `npm i @dasasian/firebase-structured-logger@beta`. For local work against a checkout, `npm link` avoids publishing entirely.
189
208
 
190
209
  ## Skills
191
210
 
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/client/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAgB,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAWxF,OAAO,EAIL,KAAK,eAAe,EACrB,MAAM,eAAe,CAAA;AAEtB,YAAY,EAAE,eAAe,EAAE,CAAA;AAE/B,KAAK,WAAW,GAAG,CAAC,IAAI,EAAE,UAAU,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;AAEzD,MAAM,WAAW,gBAAgB,CAC/B,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAEzF,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,WAAW,CAAA;IACxB,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,gBAAgB,CAAC,EAAE,eAAe,CAAA;CACnC;AAmDD,qBAAa,MAAM,CACjB,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAEzF,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA6B;IACpD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAQ;IACjC,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,UAAU,CAAyB;gBAE/B,MAAM,EAAE,gBAAgB,CAAC,SAAS,CAAC;IAQ/C,O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EACf,MAAM,CAAC,EAAE,OAAO,CAAC,SAAS,GAAG,UAAU,CAAC,EACxC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,GAAG,IAAI,GAAG,MAAM,CAAC,GACjD,IAAI;IAIP,KAAK,CACH,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,OAAO,CAAC,SAAS,GAAG,UAAU,CAAC,EACxC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,GAAG,IAAI,GAAG,MAAM,CAAC,GACjD,IAAI;YAIO,IAAI;CAmFnB;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,IAAI,IAAI,CAWrC;AAKD,wBAAgB,UAAU,CACxB,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,EACzF,MAAM,EAAE,gBAAgB,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC,CAGxD;AAED,wBAAgB,eAAe,CAC7B,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,KACtF,MAAM,CAAC,SAAS,CAAC,CAGrB"}
@@ -124,12 +124,32 @@ class Logger {
124
124
  ...this.userLabels,
125
125
  ...labels,
126
126
  };
127
+ // Each attachment is converted in its own try. A Blob or File can fail to
128
+ // read — a user picks a file from <input type="file">, moves or deletes it,
129
+ // then submits, and the browser raises NotReadableError. Previously one
130
+ // such failure escaped to the outer catch and the ENTIRE entry was lost:
131
+ // message, labels, breadcrumbs and all. The message and breadcrumbs are
132
+ // the valuable part; an attachment is a bonus.
127
133
  let base64Attachments;
134
+ const failedAttachments = [];
128
135
  if (attachments && Object.keys(attachments).length > 0) {
129
- base64Attachments = {};
136
+ const converted = {};
130
137
  for (const [name, attachment] of Object.entries(attachments)) {
131
- base64Attachments[name] = await assetToBase64(attachment);
138
+ try {
139
+ converted[name] = await assetToBase64(attachment);
140
+ }
141
+ catch (err) {
142
+ failedAttachments.push(name);
143
+ console.warn(`[fsl] Could not read attachment "${name}" — sending the log without it:`, err instanceof Error ? err.message : err);
144
+ }
132
145
  }
146
+ if (Object.keys(converted).length > 0)
147
+ base64Attachments = converted;
148
+ }
149
+ // Without this the absence of hasAttachments is a mystery. Labels are
150
+ // promoted to Cloud Logging entry labels, so this is filterable.
151
+ if (failedAttachments.length > 0) {
152
+ allLabels.attachmentsFailed = failedAttachments.join(',');
133
153
  }
134
154
  const payload = {
135
155
  message,
@@ -1 +1 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/client/logger.ts"],"names":[],"mappings":";;;AAmPA,wCAWC;AAKD,gCAKC;AAED,0CAKC;AA9QD,iDAAmD;AACnD,2CAAyD;AACzD,+CAOsB;AACtB,+CAKsB;AAgBtB,SAAS,eAAe;IACtB,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,QAAQ,KAAK,YAAY;QAAE,OAAO,SAAS,CAAA;IAC9F,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,oCAAoC;AACpC,MAAM,SAAS,GAAuB;IACpC,CAAC,kBAAkB,EAAE,KAAK,CAAC;IAC3B,CAAC,SAAS,EAAE,SAAS,CAAC;IACtB,CAAC,KAAK,EAAE,OAAO,CAAC;IAChB,CAAC,KAAK,EAAE,SAAS,CAAC;IAClB,CAAC,OAAO,EAAE,OAAO,CAAC;CACnB,CAAA;AAED,MAAM,QAAQ,GAAuB;IACnC,CAAC,SAAS,EAAE,SAAS,CAAC;IACtB,CAAC,KAAK,EAAE,MAAM,CAAC;IACf,CAAC,QAAQ,EAAE,QAAQ,C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AAc;IAC5B,OAAO,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAA;IAC3C,MAAM,MAAM,GAAG,eAAe,EAAE,CAAA;IAChC,MAAM,SAAS,GAAG,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAA;IAC/E,OAAO,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAA;IAC1C,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,YAAY,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;IACpE,OAAO,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAA;IAC5C,MAAM,CAAC,OAAO,CAAC,2BAA2B,EAAE,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC,CAAA;IACxE,OAAO,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAA;IACzC,MAAM,CAAC,IAAI,CAAC,wBAAwB,EAAE,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC,CAAA;IAClE,OAAO,CAAC,IAAI,CAAC,sFAAsF,CAAC,CAAA;AACtG,CAAC;AAED,yBAAyB;AACzB,IAAI,QAAQ,GAAsD,IAAI,CAAA;AAEtE,SAAgB,UAAU,CAExB,MAAmC;IACnC,QAAQ,GAAG,IAAI,MAAM,CAAC,MAAM,CAA+C,CAAA;IAC3E,OAAO,QAA6B,CAAA;AACtC,CAAC;AAED,SAAgB,eAAe;IAG7B,IAAI,CAAC,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAA;IAC/D,OAAO,QAA6B,CAAA;AACtC,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import type { LogWriter } from './logger';
2
2
  export { initLogger } from './logger';
3
3
  export type { LogWriter } from './logger';
4
- export { initRequestLogger, getLogger } from './requestLogger';
4
+ export { withLogging, initRequestLogger, getLogger } from './requestLogger';
5
5
  export { createClientLogHandler, createClientLogFunction } from './logHandler';
6
6
  export type { ClientLogHandlerConfig } from './logHandler';
7
7
  export type { LogSeverity, LogPayload, BaseLabels } from '../shared/types';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/functions/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEzC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACrC,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACzC,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC9D,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AAC9E,YAAY,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAA;AAC1D,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE1E,eAAO,MAAM,QAAQ,GAAI,GAAG,MAAM,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,KAAG,IAAkC,CAAA;AACrG,eAAO,MAAM,OAAO,GAAI,GAAG,MAAM,UAAU,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,KAAG,IAAoC,CAAA;AACxG,eAAO,MAAM,OAAO,GAAI,GAAG,MAAM,UAAU,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,KAAG,IAAiC,CAAA;AAClG,eAAO,MAAM,QAAQ,GAAI,GAAG,MAAM,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,KAAG,IAAkC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/functions/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEzC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACrC,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3E,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AAC9E,YAAY,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAA;AAC1D,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE1E,eAAO,MAAM,QAAQ,GAAI,GAAG,MAAM,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,KAAG,IAAkC,CAAA;AACrG,eAAO,MAAM,OAAO,GAAI,GAAG,MAAM,UAAU,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,KAAG,IAAoC,CAAA;AACxG,eAAO,MAAM,OAAO,GAAI,GAAG,MAAM,UAAU,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,KAAG,IAAiC,CAAA;AAClG,eAAO,MAAM,QAAQ,GAAI,GAAG,MAAM,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,KAAG,IAAkC,CAAA"}
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.logDebug = exports.logInfo = exports.logWarn = exports.logError = exports.createClientLogFunction = exports.createClientLogHandler = exports.getLogger = exports.initRequestLogger = exports.initLogger = void 0;
3
+ exports.logDebug = exports.logInfo = exports.logWarn = exports.logError = exports.createClientLogFunction = exports.createClientLogHandler = exports.getLogger = exports.initRequestLogger = exports.withLogging = exports.initLogger = void 0;
4
4
  const requestLogger_1 = require("./requestLogger");
5
5
  var logger_1 = require("./logger");
6
6
  Object.defineProperty(exports, "initLogger", { enumerable: true, get: function () { return logger_1.initLogger; } });
7
7
  var requestLogger_2 = require("./requestLogger");
8
+ Object.defineProperty(exports, "withLogging", { enumerable: true, get: function () { return requestLogger_2.withLogging; } });
8
9
  Object.defineProperty(exports, "initRequestLogger", { enumerable: true, get: function () { return requestLogger_2.initRequestLogger; } });
9
10
  Object.defineProperty(exports, "getLogger", { enumerable: true, get: function () { return requestLogger_2.getLogger; } });
10
11
  var logHandler_1 = require("./logHandler");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/functions/index.ts"],"names":[],"mappings":";;;AAAA,mDAA2C;AAG3C,mCAAqC;AAA5B,oGAAA,UAAU,OAAA;AAEnB,iDAA8D;AAArD,kHAAA,iBAAiB,OAAA;AAAE,0GAAA,SAAS,OAAA;AACrC,2CAA8E;AAArE,oHAAA,sBAAsB,OAAA;AAAE,qHAAA,uBAAuB,OAAA;AAIjD,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAoC,EAAQ,EAAE,CAAC,IAAA,yBAAS,GAAE,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAA;AAAxF,QAAA,QAAQ,YAAgF;AAC9F,MAAM,OAAO,GAAG,CAAC,GAAG,IAAsC,EAAQ,EAAE,CAAC,IAAA,yBAAS,GAAE,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAA;AAA3F,QAAA,OAAO,WAAoF;AACjG,MAAM,OAAO,GAAG,CAAC,GAAG,IAAmC,EAAQ,EAAE,CAAC,IAAA,yBAAS,GAAE,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAA;AAArF,QAAA,OAAO,WAA8E;AAC3F,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAoC,EAAQ,EAAE,CAAC,IAAA,yBAAS,GAAE,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAA;AAAxF,QAAA,QAAQ,YAAgF"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/functions/index.ts"],"names":[],"mappings":";;;AAAA,mDAA2C;AAG3C,mCAAqC;AAA5B,oGAAA,UAAU,OAAA;AAEnB,iDAA2E;AAAlE,4GAAA,WAAW,OAAA;AAAE,kHAAA,iBAAiB,OAAA;AAAE,0GAAA,SAAS,OAAA;AAClD,2CAA8E;AAArE,oHAAA,sBAAsB,OAAA;AAAE,qHAAA,uBAAuB,OAAA;AAIjD,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAoC,EAAQ,EAAE,CAAC,IAAA,yBAAS,GAAE,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAA;AAAxF,QAAA,QAAQ,YAAgF;AAC9F,MAAM,OAAO,GAAG,CAAC,GAAG,IAAsC,EAAQ,EAAE,CAAC,IAAA,yBAAS,GAAE,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAA;AAA3F,QAAA,OAAO,WAAoF;AACjG,MAAM,OAAO,GAAG,CAAC,GAAG,IAAmC,EAAQ,EAAE,CAAC,IAAA,yBAAS,GAAE,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAA;AAArF,QAAA,OAAO,WAA8E;AAC3F,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAoC,EAAQ,EAAE,CAAC,IAAA,yBAAS,GAAE,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAA;AAAxF,QAAA,QAAQ,YAAgF"}
@@ -1,30 +1,58 @@
1
1
  import type { CallableRequest } from 'firebase-functions/v2/https';
2
2
  import { type LogWriter } from './logger';
3
+ interface RequestLoggerOptions<AppLabels extends Record<string, string | undefined>> {
4
+ functionName?: string;
5
+ appId?: string;
6
+ labels?: Partial<AppLabels>;
7
+ }
3
8
  /**
4
- * Initialize a request-scoped logger and store it in AsyncLocalStorage.
5
- * Call at the start of every onCall handler.
9
+ * Wrap an onCall handler so every log inside it carries the request's labels.
6
10
  *
7
- * Pass AppLabels as a type parameter to get typed label checking on the `labels` field.
8
- * Any labels passed here are seeded on every log call in the request.
11
+ * This is the correct way to scope a request logger. The store is bound with
12
+ * `AsyncLocalStorage.run()`, which restores the previous context when the
13
+ * handler settles — so a request's labels cannot outlive the request.
9
14
  *
10
15
  * @example
11
- * export const myFunc = onCall(async (request) => {
12
- * initRequestLogger<AppLabels>(request, {
13
- * functionName: 'myFunc',
14
- * labels: { organizationId: request.data.organizationId },
15
- * })
16
- * logInfo('started')
17
- * })
16
+ * export const myFunc = onCall(
17
+ * withLogging<AppLabels>({ functionName: 'myFunc' }, async (request) => {
18
+ * logInfo('started')
19
+ * }),
20
+ * )
21
+ *
22
+ * Labels that depend on the request are computed per call:
23
+ *
24
+ * @example
25
+ * withLogging<AppLabels>(
26
+ * (request) => ({ functionName: 'myFunc', labels: { orgId: request.data.orgId } }),
27
+ * async (request) => { ... },
28
+ * )
18
29
  */
19
- export declare function initRequestLogger<AppLabels extends Record<string, string | undefined> = Record<string, string | undefined>>(request: CallableRequest, extra?: {
20
- functionName?: string;
21
- appId?: string;
22
- labels?: Partial<AppLabels>;
23
- }): LogWriter;
30
+ export declare function withLogging<AppLabels extends Record<string, string | undefined> = Record<string, string | undefined>, Req extends CallableRequest = CallableRequest, Res = unknown>(options: RequestLoggerOptions<AppLabels> | ((request: Req) => RequestLoggerOptions<AppLabels>), handler: (request: Req) => Res | Promise<Res>): (request: Req) => Promise<Res>;
31
+ /**
32
+ * Initialize a request-scoped logger and store it in AsyncLocalStorage.
33
+ *
34
+ * @deprecated Use {@link withLogging}. This leaks the request scope: it binds
35
+ * with `AsyncLocalStorage.enterWith()`, which persists for the remainder of the
36
+ * execution context and is never unwound. The labels therefore outlive the
37
+ * request, and any later handler that does NOT call this — a scheduled
38
+ * function, a Firestore or Storage trigger, or anything relying on
39
+ * `getLogger()`'s anonymous fallback — inherits whichever user last touched the
40
+ * warm instance.
41
+ *
42
+ * Handlers that all call this are unaffected: each overwrites the store with
43
+ * its own labels. The hazard is the handlers that do not.
44
+ *
45
+ * Removed in 0.6.0.
46
+ */
47
+ export declare function initRequestLogger<AppLabels extends Record<string, string | undefined> = Record<string, string | undefined>>(request: CallableRequest, extra?: RequestLoggerOptions<AppLabels>): LogWriter;
24
48
  /**
25
49
  * Retrieve the request-scoped logger.
26
- * Falls back to an anonymous logger (no request labels) when called outside a request context.
27
- * Logs written outside a request will be missing userId, functionName, etc. — visible in Cloud Logging.
50
+ *
51
+ * Returns an anonymous writer (no request labels) when called outside a
52
+ * request. That is only reliable when requests are scoped with
53
+ * {@link withLogging} — under the deprecated `initRequestLogger`, a previous
54
+ * request's writer can still be in scope here.
28
55
  */
29
56
  export declare function getLogger(): LogWriter;
57
+ export {};
30
58
  //# sourceMappingURL=requestLogger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"requestLogger.d.ts","sourceRoot":"","sources":["../../src/functions/requestLogger.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAClE,OAAO,EAAgC,KAAK,SAAS,EAAE,MAAM,UAAU,CAAA;AAIvE;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,EAEzF,OAAO,EAAE,eAAe,EACxB,KAAK,CAAC,EAAE;IAAE,YAAY,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAA;CAAE,GAC7E,SAAS,CAWX;AAED;;;;GAIG;AACH,wBAAgB,SAAS,IAAI,SAAS,CAErC"}
1
+ {"version":3,"file":"requestLogger.d.ts","sourceRoot":"","sources":["../../src/functions/requestLogger.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAClE,OAAO,EAAgC,KAAK,SAAS,EAAE,MAAM,UAAU,CAAA;AAIvE,UAAU,oBAAoB,CAAC,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IACjF,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAA;CAC5B;AAgBD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,WAAW,CACzB,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,EACzF,GAAG,SAAS,eAAe,GAAG,eAAe,EAC7C,GAAG,GAAG,OAAO,EAEb,OAAO,EACH,oBAAoB,CAAC,SAAS,CAAC,GAC/B,CAAC,CAAC,OAAO,EAAE,GAAG,KAAK,oBAAoB,CAAC,SAAS,CAAC,CAAC,EACvD,OAAO,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,GAC5C,CAAC,OAAO,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAMhC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,EAEzF,OAAO,EAAE,eAAe,EACxB,KAAK,CAAC,EAAE,oBAAoB,CAAC,SAAS,CAAC,GACtC,SAAS,CAKX;AAiBD;;;;;;;GAOG;AACH,wBAAgB,SAAS,IAAI,SAAS,CAErC"}
@@ -1,40 +1,90 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withLogging = withLogging;
3
4
  exports.initRequestLogger = initRequestLogger;
4
5
  exports.getLogger = getLogger;
5
6
  const async_hooks_1 = require("async_hooks");
6
7
  const logger_1 = require("./logger");
7
8
  const storage = new async_hooks_1.AsyncLocalStorage();
9
+ function writerFor(request, extra) {
10
+ return (0, logger_1.createLogWriter)((0, logger_1.cleanLabels)({
11
+ functionName: extra?.functionName,
12
+ userId: request.auth?.uid,
13
+ appId: extra?.appId,
14
+ ...extra?.labels,
15
+ }));
16
+ }
8
17
  /**
9
- * Initialize a request-scoped logger and store it in AsyncLocalStorage.
10
- * Call at the start of every onCall handler.
18
+ * Wrap an onCall handler so every log inside it carries the request's labels.
19
+ *
20
+ * This is the correct way to scope a request logger. The store is bound with
21
+ * `AsyncLocalStorage.run()`, which restores the previous context when the
22
+ * handler settles — so a request's labels cannot outlive the request.
23
+ *
24
+ * @example
25
+ * export const myFunc = onCall(
26
+ * withLogging<AppLabels>({ functionName: 'myFunc' }, async (request) => {
27
+ * logInfo('started')
28
+ * }),
29
+ * )
11
30
  *
12
- * Pass AppLabels as a type parameter to get typed label checking on the `labels` field.
13
- * Any labels passed here are seeded on every log call in the request.
31
+ * Labels that depend on the request are computed per call:
14
32
  *
15
33
  * @example
16
- * export const myFunc = onCall(async (request) => {
17
- * initRequestLogger<AppLabels>(request, {
18
- * functionName: 'myFunc',
19
- * labels: { organizationId: request.data.organizationId },
20
- * })
21
- * logInfo('started')
22
- * })
34
+ * withLogging<AppLabels>(
35
+ * (request) => ({ functionName: 'myFunc', labels: { orgId: request.data.orgId } }),
36
+ * async (request) => { ... },
37
+ * )
38
+ */
39
+ function withLogging(options, handler) {
40
+ return (request) => {
41
+ const resolved = typeof options === 'function' ? options(request) : options;
42
+ const writer = writerFor(request, resolved);
43
+ return storage.run(writer, async () => handler(request));
44
+ };
45
+ }
46
+ /**
47
+ * Initialize a request-scoped logger and store it in AsyncLocalStorage.
48
+ *
49
+ * @deprecated Use {@link withLogging}. This leaks the request scope: it binds
50
+ * with `AsyncLocalStorage.enterWith()`, which persists for the remainder of the
51
+ * execution context and is never unwound. The labels therefore outlive the
52
+ * request, and any later handler that does NOT call this — a scheduled
53
+ * function, a Firestore or Storage trigger, or anything relying on
54
+ * `getLogger()`'s anonymous fallback — inherits whichever user last touched the
55
+ * warm instance.
56
+ *
57
+ * Handlers that all call this are unaffected: each overwrites the store with
58
+ * its own labels. The hazard is the handlers that do not.
59
+ *
60
+ * Removed in 0.6.0.
23
61
  */
24
62
  function initRequestLogger(request, extra) {
25
- const writer = (0, logger_1.createLogWriter)((0, logger_1.cleanLabels)({
26
- functionName: extra?.functionName,
27
- userId: request.auth?.uid,
28
- appId: extra?.appId,
29
- ...extra?.labels,
30
- }));
63
+ warnDeprecated(extra?.functionName);
64
+ const writer = writerFor(request, extra);
31
65
  storage.enterWith(writer);
32
66
  return writer;
33
67
  }
68
+ // Warn once per function name rather than per invocation — a per-request warning
69
+ // on a hot path is noise that gets filtered out and then ignored.
70
+ const warned = new Set();
71
+ function warnDeprecated(functionName) {
72
+ const key = functionName ?? '(unnamed)';
73
+ if (warned.has(key))
74
+ return;
75
+ warned.add(key);
76
+ console.warn(`[fsl] initRequestLogger() is deprecated (${key}). It binds the request scope with ` +
77
+ 'enterWith(), which is never unwound — the labels outlive the request, so a later ' +
78
+ 'handler that does not call it inherits this request\'s userId. Wrap the handler ' +
79
+ 'with withLogging() instead. Removed in 0.6.0.');
80
+ }
34
81
  /**
35
82
  * Retrieve the request-scoped logger.
36
- * Falls back to an anonymous logger (no request labels) when called outside a request context.
37
- * Logs written outside a request will be missing userId, functionName, etc. — visible in Cloud Logging.
83
+ *
84
+ * Returns an anonymous writer (no request labels) when called outside a
85
+ * request. That is only reliable when requests are scoped with
86
+ * {@link withLogging} — under the deprecated `initRequestLogger`, a previous
87
+ * request's writer can still be in scope here.
38
88
  */
39
89
  function getLogger() {
40
90
  return storage.getStore() ?? (0, logger_1.createLogWriter)({});
@@ -1 +1 @@
1
- {"version":3,"file":"requestLogger.js","sourceRoot":"","sources":["../../src/functions/requestLogger.ts"],"names":[],"mappings":";;AAsBA,8CAgBC;AAOD,8BAEC;AA/CD,6CAA+C;AAE/C,qCAAuE;AAEvE,MAAM,OAAO,GAAG,IAAI,+BAAiB,EAAa,CAAA;AAElD;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,iBAAiB,CAG/B,OAAwB,EACxB,KAA8E;IAE9E,MAAM,MAAM,GAAG,IAAA,wBAAe,EAC5B,IAAA,oBAAW,EAAC;QACV,YAAY,EAAE,KAAK,EAAE,YAA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CAAC,CAAC,CAAA;IAC1D,CAAC,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,iBAAiB,CAG/B,OAAwB,EACxB,KAAuC;IAEvC,cAAc,CAAC,KAAK,EAAE,YAAY,CAAC,CAAA;IACnC,MAAM,MAAM,GAAG,SAAS,CAAY,OAAO,EAAE,KAAK,CAAC,CAAA;IACnD,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;IACzB,OAAO,MAAM,CAAA;AACf,CAAC;AAED,iFAAiF;AACjF,kEAAkE;AAClE,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAA;AAChC,SAAS,cAAc,CAAC,YAAgC;IACtD,MAAM,GAAG,GAAG,YAAY,IAAI,WAAW,CAAA;IACvC,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC;QAAE,OAAM;IAC3B,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IACf,OAAO,CAAC,IAAI,CACV,4CAA4C,GAAG,qCAAqC;QAClF,mFAAmF;QACnF,kFAAkF;QAClF,+CAA+C,CAClD,CAAA;AACH,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,SAAS;IACvB,OAAO,OAAO,CAAC,QAAQ,EAAE,IAAI,IAAA,wBAAe,EAAC,EAAE,CAAC,CAAA;AAClD,CAAC"}
@@ -1,5 +1,24 @@
1
1
  import type { Bucket } from '@google-cloud/storage';
2
2
  import type { EncodedSourceMap } from '@jridgewell/trace-mapping';
3
+ interface CacheEntry {
4
+ map: EncodedSourceMap | null;
5
+ bytes: number;
6
+ }
7
+ /**
8
+ * Test-only handle on the cache internals. Not exported from the package entry
9
+ * point, so it is not public API — the eviction policy is worth asserting
10
+ * directly rather than inferring from behaviour through a live bucket.
11
+ */
12
+ export declare const __cacheForTests: {
13
+ get: (key: string) => CacheEntry | undefined;
14
+ set: (key: string, map: EncodedSourceMap | null, bytes: number) => void;
15
+ clear: () => void;
16
+ stats: () => {
17
+ entries: number;
18
+ bytes: number;
19
+ limit: number;
20
+ };
21
+ };
3
22
  export declare function configureSourceMapBucket(bucketName: string): void;
4
23
  /**
5
24
  * Resolve the configured Storage bucket, falling back to the project default.
@@ -12,6 +31,25 @@ export declare function getBucket(bucketName?: string | undefined): Bucket;
12
31
  /**
13
32
  * Get source map — checks embedded first (instant), then Storage (for old releases).
14
33
  */
34
+ /**
35
+ * Resolve the source map for a bundle in a given release.
36
+ *
37
+ * The embedded directory is keyed by filename alone and holds exactly one
38
+ * release's maps, so preferring it unconditionally meant an old stack could be
39
+ * resolved with the CURRENT release's map — plausible-looking wrong line
40
+ * numbers, which is worse than none. But requiring an exact match would break
41
+ * apps that simply deploy and never version anything: they have one release's
42
+ * maps, never need Storage, and their releaseId will not match a marker.
43
+ *
44
+ * So Storage is preferred only when it actually has something better:
45
+ *
46
+ * matches the embedded release -> embedded, no network
47
+ * differs -> Storage, falling back to embedded on a miss
48
+ *
49
+ * That is strictly better than preferring embedded in every case, and it leaves
50
+ * the unversioned setup working exactly as before.
51
+ */
15
52
  export declare function getSourceMap(releaseId: string, fileName: string, bucketName?: string): Promise<EncodedSourceMap | null>;
16
53
  export declare function clearSourceMapCache(): void;
54
+ export {};
17
55
  //# sourceMappingURL=sourceMapCache.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sourceMapCache.d.ts","sourceRoot":"","sources":["../../src/functions/sourceMapCache.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAcjE,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAEjE;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,UAAU,qBAAgB,GAAG,MAAM,CAE5D;AA4DD;;GAEG;AACH,wBAAsB,YAAY,CAChC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAIlC;AAED,wBAAgB,mBAAmB,IAAI,IAAI,CAG1C"}
1
+ {"version":3,"file":"sourceMapCache.d.ts","sourceRoot":"","sources":["../../src/functions/sourceMapCache.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAkBjE,UAAU,UAAU;IAClB,GAAG,EAAE,gBAAgB,GAAG,IAAI,CAAA;IAC5B,KAAK,EAAE,MAAM,CAAA;CACd;AAgCD;;;;GAIG;AACH,eAAO,MAAM,eAAe;eACf,MAAM;eACN,MAAM,OAAO,gBAAgB,GAAG,IAAI,SAAS,MAAM;;;;;;;CAG/D,CAAA;AAuBD,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAEjE;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,UAAU,qBAAgB,GAAG,MAAM,CAE5D;AA6ED;;GAEG;AACH;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,YAAY,CAChC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAgBlC;AAiBD,wBAAgB,mBAAmB,IAAI,IAAI,CAM1C"}
@@ -33,6 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.__cacheForTests = void 0;
36
37
  exports.configureSourceMapBucket = configureSourceMapBucket;
37
38
  exports.getBucket = getBucket;
38
39
  exports.getSourceMap = getSourceMap;
@@ -40,10 +41,74 @@ exports.clearSourceMapCache = clearSourceMapCache;
40
41
  const fs = __importStar(require("fs"));
41
42
  const path = __importStar(require("path"));
42
43
  const storage_1 = require("firebase-admin/storage");
43
- // In-memory cache: cacheKey → EncodedSourceMap | null (null = confirmed not found)
44
+ /**
45
+ * Storage-map cache, bounded by approximate bytes with LRU eviction.
46
+ *
47
+ * This grows with releases x bundles and lives for the instance's lifetime, so
48
+ * unbounded it is a plausible out-of-memory on a 256MB Cloud Function —
49
+ * presenting as random instance crashes rather than a logging fault, which is
50
+ * miserable to attribute. A real Vite map is ~580KB after `sourcesContent` is
51
+ * stripped, and maps uploaded before 0.4.0 still carry theirs at ~2.2MB.
52
+ *
53
+ * Negative entries (null = confirmed not found) are exempt from the budget.
54
+ * They cost nothing and each one prevents a repeated Storage round-trip on the
55
+ * per-error path — more valuable since a release mismatch now consults Storage
56
+ * first and usually misses.
57
+ */
58
+ const MAX_CACHE_BYTES = 64 * 1024 * 1024;
44
59
  const cache = new Map();
45
- // Separate cache for the embedded (current release) maps, keyed by bundle filename.
60
+ let cacheBytes = 0;
61
+ /** Read, moving the entry to the most-recent position. */
62
+ function cacheGet(key) {
63
+ const entry = cache.get(key);
64
+ if (!entry)
65
+ return undefined;
66
+ // Map iterates in insertion order, so delete + re-insert makes it LRU.
67
+ cache.delete(key);
68
+ cache.set(key, entry);
69
+ return entry;
70
+ }
71
+ function cacheSet(key, map, bytes) {
72
+ const existing = cache.get(key);
73
+ if (existing)
74
+ cacheBytes -= existing.bytes;
75
+ const size = map === null ? 0 : bytes;
76
+ cache.set(key, { map, bytes: size });
77
+ cacheBytes += size;
78
+ // Evict oldest first, skipping negative entries — they are free and useful.
79
+ for (const [k, entry] of cache) {
80
+ if (cacheBytes <= MAX_CACHE_BYTES)
81
+ break;
82
+ if (k === key || entry.map === null)
83
+ continue;
84
+ cache.delete(k);
85
+ cacheBytes -= entry.bytes;
86
+ }
87
+ }
88
+ /**
89
+ * Test-only handle on the cache internals. Not exported from the package entry
90
+ * point, so it is not public API — the eviction policy is worth asserting
91
+ * directly rather than inferring from behaviour through a live bucket.
92
+ */
93
+ exports.__cacheForTests = {
94
+ get: (key) => cacheGet(key),
95
+ set: (key, map, bytes) => cacheSet(key, map, bytes),
96
+ clear: () => clearSourceMapCache(),
97
+ stats: () => ({ entries: cache.size, bytes: cacheBytes, limit: MAX_CACHE_BYTES }),
98
+ };
99
+ /**
100
+ * Embedded (deployed release) maps, keyed by bundle filename.
101
+ *
102
+ * Deliberately unbounded: this only ever holds the maps for the one release the
103
+ * function was deployed with, so it is bounded by that build's chunk count and
104
+ * every entry is hot. The Storage cache is the one that grows without limit —
105
+ * it accumulates across releases.
106
+ */
46
107
  const embeddedCache = new Map();
108
+ // Which release the embedded maps belong to, written by
109
+ // `fsl upload-sourcemaps --embed-sourcemaps`. undefined = not yet read,
110
+ // null = no marker (older deploys, or embedding was never used).
111
+ let embeddedRelease;
47
112
  // Process-wide fallback bucket. Used by writeLog() for attachments, which has
48
113
  // no per-handler config to draw on. Source-map lookups do NOT rely on this —
49
114
  // they take the bucket explicitly, so two handlers configured with different
@@ -75,6 +140,21 @@ function loadEmbeddedSourceMap(fileName) {
75
140
  embeddedCache.set(fileName, sourceMap);
76
141
  return sourceMap;
77
142
  }
143
+ /** The release the embedded maps were built from, or null if unmarked. */
144
+ function readEmbeddedRelease() {
145
+ if (embeddedRelease !== undefined)
146
+ return embeddedRelease;
147
+ try {
148
+ const markerPath = path.join(process.cwd(), 'sourcemaps', 'current', '.release');
149
+ embeddedRelease = fs.existsSync(markerPath)
150
+ ? fs.readFileSync(markerPath, 'utf-8').trim() || null
151
+ : null;
152
+ }
153
+ catch {
154
+ embeddedRelease = null;
155
+ }
156
+ return embeddedRelease;
157
+ }
78
158
  function readEmbeddedSourceMap(fileName) {
79
159
  try {
80
160
  // Looks for sourcemaps/current/{fileName}.map relative to the Cloud Function working directory
@@ -94,37 +174,84 @@ async function loadStorageSourceMap(releaseId, fileName, bucketName) {
94
174
  // The bucket is part of the key: the same release/file in two buckets is two
95
175
  // different maps, and caching them under one key would serve the wrong one.
96
176
  const cacheKey = `${bucketName ?? defaultBucket ?? ''}/${releaseId}/${fileName}`;
97
- if (cache.has(cacheKey))
98
- return cache.get(cacheKey) ?? null;
177
+ const hit = cacheGet(cacheKey);
178
+ if (hit)
179
+ return hit.map;
99
180
  try {
100
181
  const file = getBucket(bucketName).file(`sourcemaps/${releaseId}/${fileName}.map`);
101
182
  const [exists] = await file.exists();
102
183
  if (!exists) {
103
- cache.set(cacheKey, null);
184
+ cacheSet(cacheKey, null, 0);
104
185
  return null;
105
186
  }
106
187
  const [content] = await file.download();
107
188
  const sourceMap = JSON.parse(content.toString());
108
- cache.set(cacheKey, sourceMap);
189
+ // content.length is the byte size we already hold — no re-serialising a
190
+ // half-megabyte object just to measure it.
191
+ cacheSet(cacheKey, sourceMap, content.length);
109
192
  return sourceMap;
110
193
  }
111
194
  catch (err) {
112
195
  console.warn(`[fsl] Failed to load Storage map for ${releaseId}/${fileName}:`, err);
113
- cache.set(cacheKey, null);
196
+ cacheSet(cacheKey, null, 0);
114
197
  return null;
115
198
  }
116
199
  }
117
200
  /**
118
201
  * Get source map — checks embedded first (instant), then Storage (for old releases).
119
202
  */
203
+ /**
204
+ * Resolve the source map for a bundle in a given release.
205
+ *
206
+ * The embedded directory is keyed by filename alone and holds exactly one
207
+ * release's maps, so preferring it unconditionally meant an old stack could be
208
+ * resolved with the CURRENT release's map — plausible-looking wrong line
209
+ * numbers, which is worse than none. But requiring an exact match would break
210
+ * apps that simply deploy and never version anything: they have one release's
211
+ * maps, never need Storage, and their releaseId will not match a marker.
212
+ *
213
+ * So Storage is preferred only when it actually has something better:
214
+ *
215
+ * matches the embedded release -> embedded, no network
216
+ * differs -> Storage, falling back to embedded on a miss
217
+ *
218
+ * That is strictly better than preferring embedded in every case, and it leaves
219
+ * the unversioned setup working exactly as before.
220
+ */
120
221
  async function getSourceMap(releaseId, fileName, bucketName) {
121
222
  const embedded = loadEmbeddedSourceMap(fileName);
122
- if (embedded)
223
+ const marker = readEmbeddedRelease();
224
+ // No marker means we cannot tell whether this stack belongs to the embedded
225
+ // release. Older deploys have none, so keep the previous behaviour.
226
+ if (embedded && (marker === null || marker === releaseId))
123
227
  return embedded;
124
- return loadStorageSourceMap(releaseId, fileName, bucketName);
228
+ const stored = await loadStorageSourceMap(releaseId, fileName, bucketName);
229
+ if (stored)
230
+ return stored;
231
+ if (embedded) {
232
+ warnReleaseFallback(releaseId, marker);
233
+ return embedded;
234
+ }
235
+ return null;
236
+ }
237
+ // Warn once per (release, marker) pair — this sits on the per-error path.
238
+ const warnedFallbacks = new Set();
239
+ function warnReleaseFallback(releaseId, marker) {
240
+ const key = `${releaseId}|${marker}`;
241
+ if (warnedFallbacks.has(key))
242
+ return;
243
+ warnedFallbacks.add(key);
244
+ console.warn(`[fsl] Stack is from release '${releaseId}' but the deployed maps are for ` +
245
+ `'${marker}', and Storage has no map for '${releaseId}'. Symbolicating with ` +
246
+ 'the deployed maps — line numbers may be wrong if the bundle changed between ' +
247
+ 'releases. If you did not mean to version releases, ignore this; if you did, ' +
248
+ 'check that the client\'s releaseId matches the one used at upload time.');
125
249
  }
126
250
  function clearSourceMapCache() {
127
251
  cache.clear();
252
+ cacheBytes = 0;
128
253
  embeddedCache.clear();
254
+ embeddedRelease = undefined;
255
+ warnedFallbacks.clear();
129
256
  }
130
257
  //# sourceMappingURL=sourceMapCache.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sourceMapCache.js","sourceRoot":"","sources":["../../src/functions/sourceMapCache.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,4DAEC;AASD,8BAEC;AA+DD,oCAQC;AAED,kDAGC;AA3GD,uCAAwB;AACxB,2CAA4B;AAC5B,oDAAmD;AAInD,mFAAmF;AACnF,MAAM,KAAK,GAAG,IAAI,GAAG,EAAmC,CAAA;AAExD,oFAAoF;AACpF,MAAM,aAAa,GAAG,IAAI,GAAG,EAAmC,CAAA;AAEhE,8EAA8E;AAC9E,6EAA6E;AAC7E,6EAA6E;AAC7E,qEAAqE;AACrE,IAA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U,GAAG,CAAC,CAAA;IACd,aAAa,CAAC,KAAK,EAAE,CAAA;IACrB,eAAe,GAAG,SAAS,CAAA;IAC3B,eAAe,CAAC,KAAK,EAAE,CAAA;AACzB,CAAC"}
@@ -38,7 +38,6 @@ const fs = __importStar(require("fs"));
38
38
  const path = __importStar(require("path"));
39
39
  const uploadSourceMaps_1 = require("./uploadSourceMaps");
40
40
  const installSkills_1 = require("./installSkills");
41
- const packDeploy_1 = require("./packDeploy");
42
41
  const [, , command, ...rawArgs] = process.argv;
43
42
  function parseArgs(args) {
44
43
  const result = {};
@@ -85,35 +84,23 @@ async function main() {
85
84
  console.error('Bucket can also be set via VITE_FIREBASE_STORAGE_BUCKET or FIREBASE_STORAGE_BUCKET env var (loaded from .env.local automatically).');
86
85
  process.exit(1);
87
86
  }
88
- await (0, uploadSourceMaps_1.uploadSourceMaps)({
87
+ const result = await (0, uploadSourceMaps_1.uploadSourceMaps)({
89
88
  bucket,
90
89
  release: args.release,
91
90
  distDir: args.dist,
92
91
  functionsDir: args.functions,
93
92
  embedSourcemaps: args['embed-sourcemaps'] === 'true',
94
93
  });
94
+ // Distinct code so a deploy chain can choose to continue:
95
+ // npx fsl upload-sourcemaps … || [ $? -eq 3 ]
96
+ if (!result.uploaded)
97
+ process.exit(uploadSourceMaps_1.EXIT_UPLOAD_FAILED_BUT_EMBEDDED);
95
98
  break;
96
99
  }
97
100
  case 'install-skills': {
98
101
  await (0, installSkills_1.installSkills)({ global: args.global === 'true', force: args.force === 'true' });
99
102
  break;
100
103
  }
101
- case 'pack': {
102
- if (!args.functions) {
103
- console.error('Usage: fsl pack --functions=<path>');
104
- process.exit(1);
105
- }
106
- await (0, packDeploy_1.pack)({ functionsDir: args.functions });
107
- break;
108
- }
109
- case 'pack-restore': {
110
- if (!args.functions) {
111
- console.error('Usage: fsl pack-restore --functions=<path>');
112
- process.exit(1);
113
- }
114
- await (0, packDeploy_1.packRestore)({ functionsDir: args.functions });
115
- break;
116
- }
117
104
  default: {
118
105
  console.log(`
119
106
  firebase-structured-logger (fsl)
@@ -131,12 +118,7 @@ Commands:
131
118
  Copy skills/ to .claude/skills/ (project) or ~/.claude/skills/ (--global).
132
119
  Prompts before overwriting existing skills. Use --force to skip prompts.
133
120
 
134
- fsl pack --functions=<path>
135
- Build + pack firebase-structured-logger, copy tgz to functions/vendor/,
136
- and patch functions/package.json. Run before firebase deploy.
137
121
 
138
- fsl pack-restore --functions=<path>
139
- Restore functions/package.json to its file: reference after deploy.
140
122
  `);
141
123
  if (command) {
142
124
  console.error(`Unknown command: ${command}`);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,uCAAwB;AACxB,2CAA4B;AAC5B,yDAAqD;AACrD,mDAA+C;AAC/C,6CAAgD;AAEhD,MAAM,CAAC,EAAE,AAAD,EAAG,OAAO,EAAE,GAAG,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAA;AAE9C,SAAS,SAAS,CAAC,IAAc;IAC/B,MAAM,MAAM,GAA2B,EAAE,CAAA;IACzC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAA;QAC3C,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;QAC7B,CAAC;aAAM,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YAChC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAA;QAC/B,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAED,SAAS,WAAW,CAAC,QAAgB;IACnC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAA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C,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,KAAK,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,KAAK,MAAM,EAAE,CAAC,CAAA;YACrF,MAAK;QACP,CAAC;QAED,OAAO,CAAC,CAAC,CAAC;YACR,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;CAiBjB,CAAC,CAAA;YACI,IAAI,OAAO,EAAE,CAAC;gBACZ,OAAO,CAAC,KAAK,CAAC,oBAAoB,OAAO,EAAE,CAAC,CAAA;gBAC5C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;YACjB,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAClB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA"}
@@ -1,3 +1,21 @@
1
+ /**
2
+ * Exit code used when maps were embedded but the Storage upload failed.
3
+ *
4
+ * Distinct from 1 so a deploy script can decide: `|| [ $? -eq 3 ]` to continue
5
+ * anyway, or let it stop the chain. Exiting 0 was too quiet — the deploy script
6
+ * is a `&&` chain, so the deploy proceeded and the only signal was a warning
7
+ * scrolling past in CI output.
8
+ */
9
+ export declare const EXIT_UPLOAD_FAILED_BUT_EMBEDDED = 3;
10
+ /**
11
+ * Records which release the embedded maps belong to.
12
+ *
13
+ * Without it the runtime cannot tell "this stack is from the deployed release"
14
+ * from "this stack is from an older one" — the embedded directory is keyed only
15
+ * by filename, so an old stack naming a bundle that still exists would be
16
+ * resolved with the current map, giving confidently wrong line numbers.
17
+ */
18
+ export declare const EMBEDDED_RELEASE_MARKER = ".release";
1
19
  export interface UploadOptions {
2
20
  bucket: string;
3
21
  release?: string;
@@ -5,5 +23,28 @@ export interface UploadOptions {
5
23
  functionsDir?: string;
6
24
  embedSourcemaps?: boolean;
7
25
  }
8
- export declare function uploadSourceMaps(options: UploadOptions): Promise<void>;
26
+ /**
27
+ * Drop `sourcesContent` from a source map, returning the JSON to store.
28
+ *
29
+ * `sourcesContent` inlines the ENTIRE original source of every file the bundle
30
+ * covers. Symbolication never reads it — `originalPositionFor` needs only
31
+ * `sources`, `names` and `mappings` — so uploading it costs storage, download
32
+ * time on the per-error path, and Cloud Function memory, for nothing.
33
+ *
34
+ * It is also your source code. Uploading maps verbatim means a logging tool
35
+ * quietly ships your source into a Storage bucket, where a misconfiguration
36
+ * turns a logging concern into a source-code leak.
37
+ *
38
+ * Measured on a real Vite bundle: 2.23 MB -> 580 KB, a 74.6% reduction.
39
+ *
40
+ * Returns the original text unchanged if it is not parseable JSON, so an odd
41
+ * map is uploaded as-is rather than lost.
42
+ */
43
+ export declare function stripSourcesContent(raw: string): {
44
+ json: string;
45
+ stripped: boolean;
46
+ };
47
+ export declare function uploadSourceMaps(options: UploadOptions): Promise<{
48
+ uploaded: boolean;
49
+ }>;
9
50
  //# sourceMappingURL=uploadSourceMaps.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"uploadSourceMaps.d.ts","sourceRoot":"","sources":["../../src/tools/uploadSourceMaps.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B;AAsBD,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAmE5E"}
1
+ {"version":3,"file":"uploadSourceMaps.d.ts","sourceRoot":"","sources":["../../src/tools/uploadSourceMaps.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,eAAO,MAAM,+BAA+B,IAAI,CAAA;AAEhD;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,aAAa,CAAA;AAEjD,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,CASpF;AA8BD,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC;IAAE,QAAQ,EAAE,OAAO,CAAA;CAAE,CAAC,CAmF7F"}
@@ -33,10 +33,65 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.EMBEDDED_RELEASE_MARKER = exports.EXIT_UPLOAD_FAILED_BUT_EMBEDDED = void 0;
37
+ exports.stripSourcesContent = stripSourcesContent;
36
38
  exports.uploadSourceMaps = uploadSourceMaps;
37
39
  const fs = __importStar(require("fs"));
38
40
  const path = __importStar(require("path"));
39
41
  const storage_1 = require("@google-cloud/storage");
42
+ /**
43
+ * Exit code used when maps were embedded but the Storage upload failed.
44
+ *
45
+ * Distinct from 1 so a deploy script can decide: `|| [ $? -eq 3 ]` to continue
46
+ * anyway, or let it stop the chain. Exiting 0 was too quiet — the deploy script
47
+ * is a `&&` chain, so the deploy proceeded and the only signal was a warning
48
+ * scrolling past in CI output.
49
+ */
50
+ exports.EXIT_UPLOAD_FAILED_BUT_EMBEDDED = 3;
51
+ /**
52
+ * Records which release the embedded maps belong to.
53
+ *
54
+ * Without it the runtime cannot tell "this stack is from the deployed release"
55
+ * from "this stack is from an older one" — the embedded directory is keyed only
56
+ * by filename, so an old stack naming a bundle that still exists would be
57
+ * resolved with the current map, giving confidently wrong line numbers.
58
+ */
59
+ exports.EMBEDDED_RELEASE_MARKER = '.release';
60
+ /**
61
+ * Drop `sourcesContent` from a source map, returning the JSON to store.
62
+ *
63
+ * `sourcesContent` inlines the ENTIRE original source of every file the bundle
64
+ * covers. Symbolication never reads it — `originalPositionFor` needs only
65
+ * `sources`, `names` and `mappings` — so uploading it costs storage, download
66
+ * time on the per-error path, and Cloud Function memory, for nothing.
67
+ *
68
+ * It is also your source code. Uploading maps verbatim means a logging tool
69
+ * quietly ships your source into a Storage bucket, where a misconfiguration
70
+ * turns a logging concern into a source-code leak.
71
+ *
72
+ * Measured on a real Vite bundle: 2.23 MB -> 580 KB, a 74.6% reduction.
73
+ *
74
+ * Returns the original text unchanged if it is not parseable JSON, so an odd
75
+ * map is uploaded as-is rather than lost.
76
+ */
77
+ function stripSourcesContent(raw) {
78
+ try {
79
+ const map = JSON.parse(raw);
80
+ if (!('sourcesContent' in map))
81
+ return { json: raw, stripped: false };
82
+ delete map.sourcesContent;
83
+ return { json: JSON.stringify(map), stripped: true };
84
+ }
85
+ catch {
86
+ return { json: raw, stripped: false };
87
+ }
88
+ }
89
+ function readStrippedMap(localPath) {
90
+ const raw = fs.readFileSync(localPath, 'utf-8');
91
+ const { json } = stripSourcesContent(raw);
92
+ return { json, before: Buffer.byteLength(raw), after: Buffer.byteLength(json) };
93
+ }
94
+ const kb = (bytes) => `${Math.round(bytes / 1024)}KB`;
40
95
  function findMapFiles(dir) {
41
96
  const results = [];
42
97
  if (!fs.existsSync(dir))
@@ -65,7 +120,7 @@ async function uploadSourceMaps(options) {
65
120
  const mapFiles = findMapFiles(distDir);
66
121
  if (mapFiles.length === 0) {
67
122
  console.log('[fsl] No .map files found in', distDir);
68
- return;
123
+ return { uploaded: true };
69
124
  }
70
125
  console.log(`[fsl] Uploading ${mapFiles.length} source map(s) for release ${releaseId}...`);
71
126
  // Embed maps into functions directory before uploading (for fast lookup of current release)
@@ -77,8 +132,12 @@ async function uploadSourceMaps(options) {
77
132
  }
78
133
  for (const localPath of mapFiles) {
79
134
  const dest = path.join(embedDir, path.basename(localPath));
80
- fs.copyFileSync(localPath, dest);
81
- console.log(` ✓ embedded ${path.basename(localPath)} ${options.functionsDir}/sourcemaps/current/`);
135
+ // Stripped here too: these ship inside the deployed function, so the
136
+ // content would inflate the deploy and sit in memory for the instance's life.
137
+ const { json, before, after } = readStrippedMap(localPath);
138
+ fs.writeFileSync(dest, json);
139
+ const saved = before > after ? ` (${kb(before)} → ${kb(after)})` : '';
140
+ console.log(` ✓ embedded ${path.basename(localPath)} → ${options.functionsDir}/sourcemaps/current/${saved}`);
82
141
  }
83
142
  }
84
143
  // Authenticate via service account key if available, otherwise fall back to ADC
@@ -92,29 +151,39 @@ async function uploadSourceMaps(options) {
92
151
  for (const localPath of mapFiles) {
93
152
  const fileName = path.basename(localPath);
94
153
  const destination = `sourcemaps/${releaseId}/${fileName}`;
95
- await bucket.upload(localPath, { destination });
96
- console.log(` ✓ ${fileName} gs://${options.bucket}/${destination}`);
154
+ const { json, before, after } = readStrippedMap(localPath);
155
+ await bucket.file(destination).save(json, { contentType: 'application/json' });
156
+ const saved = before > after ? ` (${kb(before)} → ${kb(after)}, -${Math.round(100 - (after / before) * 100)}%)` : '';
157
+ console.log(` ✓ ${fileName} → gs://${options.bucket}/${destination}${saved}`);
97
158
  // Delete local .map file after upload
98
159
  fs.unlinkSync(localPath);
99
160
  console.log(` ✗ deleted ${path.relative(process.cwd(), localPath)}`);
100
161
  }
101
162
  console.log('[fsl] Source map upload complete.');
163
+ return { uploaded: true };
102
164
  }
103
165
  catch (err) {
104
- if (options.embedSourcemaps) {
105
- console.warn('[fsl] Warning: GCS upload failed — symbolication will work for this release only (via embedded maps). Previous releases will not be symbolicated.');
106
- console.warn('[fsl] GCS error:', err?.message ?? err);
107
- // Delete local .map files even though GCS upload failed — they are embedded and should not be deployed to hosting
108
- for (const localPath of mapFiles) {
109
- if (fs.existsSync(localPath)) {
110
- fs.unlinkSync(localPath);
111
- console.log(` ✗ deleted ${path.relative(process.cwd(), localPath)}`);
112
- }
113
- }
114
- }
115
- else {
166
+ if (!options.embedSourcemaps)
116
167
  throw err;
168
+ // Be precise about the consequence. Previous releases are unaffected —
169
+ // their maps reached Storage on earlier runs. What is at risk is THIS
170
+ // release: its maps never got there, and the embedded copy lives in
171
+ // {functionsDir}/sourcemaps/current/, which the next deploy wipes.
172
+ console.warn(`[fsl] GCS upload FAILED for release ${releaseId}.`);
173
+ console.warn('[fsl] GCS error:', err?.message ?? err);
174
+ console.warn(`[fsl] Errors from ${releaseId} will still symbolicate while it is the deployed`);
175
+ console.warn('[fsl] release, because the embedded copy is checked first. Once a newer release');
176
+ console.warn(`[fsl] is deployed, sourcemaps/current/ is replaced and ${releaseId} can no`);
177
+ console.warn('[fsl] longer be symbolicated. Re-run upload-sourcemaps before deploying again.');
178
+ // Deleted regardless: the maps are embedded, and leaving them in dist/ would
179
+ // ship source maps to browsers, which is the worse outcome.
180
+ for (const localPath of mapFiles) {
181
+ if (fs.existsSync(localPath)) {
182
+ fs.unlinkSync(localPath);
183
+ console.log(` ✗ deleted ${path.relative(process.cwd(), localPath)}`);
184
+ }
117
185
  }
186
+ return { uploaded: false };
118
187
  }
119
188
  }
120
189
  //# sourceMappingURL=uploadSourceMaps.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"uploadSourceMaps.js","sourceRoot":"","sources":["../../src/tools/uploadSourceMaps.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,4CAmEC;AAnGD,uCAAwB;AACxB,2CAA4B;AAC5B,mDAA+C;AAU/C,SAAS,YAAY,CAAC,GAAW;IAC/B,MAAM,OAAO,GAAa,EAAE,CAAA;IAE5B,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,OAAO,CAAA;IAEvC,SAAS,IAAI,CAAC,OAAe;QAC3B,KAAK,MAAM,KAAK,IAAI,EAAE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C,GAAG,CAAC,eAAe,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,CAAC,EAAE,CAAC,CAAA;YACvE,CAAC;QACH,CAAC;QACD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAA;IAC5B,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dasasian/firebase-structured-logger",
3
- "version": "0.4.0-beta.0",
3
+ "version": "0.5.0-beta.0",
4
4
  "description": "Structured logging for Firebase apps \u2014 client, functions, and tools",
5
5
  "license": "MIT",
6
6
  "author": "Dasasian",
@@ -65,8 +65,8 @@
65
65
  "build:watch": "tsc --watch",
66
66
  "clean": "rm -rf dist",
67
67
  "typecheck": "tsc --noEmit",
68
- "test": "tsx tests/logger.ts && tsx tests/breadcrumbs.ts && tsx tests/rateLimiter.ts && tsx tests/errorHandler.ts && tsx tests/attachments.ts && FUNCTIONS_EMULATOR=true tsx tests/errorPayload.ts && FUNCTIONS_EMULATOR=true tsx tests/requestLogger.ts && FUNCTIONS_EMULATOR=true tsx tests/handler.ts && FUNCTIONS_EMULATOR=true tsx tests/symbolication.ts && FUNCTIONS_EMULATOR=true tsx tests/publicApi.ts && FUNCTIONS_EMULATOR=true tsx tests/configureTwice.ts && tsx tests/productionOutput.ts && tsx tests/handlerSymbolication.ts",
69
- "prepublishOnly": "npm run build",
68
+ "test": "tsx tests/logger.ts && tsx tests/breadcrumbs.ts && tsx tests/rateLimiter.ts && tsx tests/errorHandler.ts && tsx tests/attachments.ts && tsx tests/sourceMapStripping.ts && FUNCTIONS_EMULATOR=true tsx tests/errorPayload.ts && FUNCTIONS_EMULATOR=true tsx tests/requestLogger.ts && FUNCTIONS_EMULATOR=true tsx tests/handler.ts && FUNCTIONS_EMULATOR=true tsx tests/symbolication.ts && FUNCTIONS_EMULATOR=true tsx tests/publicApi.ts && FUNCTIONS_EMULATOR=true tsx tests/configureTwice.ts && tsx tests/productionOutput.ts && tsx tests/handlerSymbolication.ts && tsx tests/releaseResolution.ts && tsx tests/sourceMapCacheBounds.ts",
69
+ "prepublishOnly": "npm run clean && npm run build",
70
70
  "smoke:deploy": "cd smoke/functions && npm install && npm run build && cd .. && firebase deploy --only functions --project $(grep '^FSL_SMOKE_PROJECT=' .env.local | cut -d= -f2)",
71
71
  "smoke": "tsx smoke/run.ts"
72
72
  },
@@ -1,15 +0,0 @@
1
- interface PackOptions {
2
- functionsDir: string;
3
- }
4
- /**
5
- * Build + pack firebase-structured-logger, copy tgz to functions/vendor/,
6
- * and patch functions/package.json to reference it. Call before firebase deploy.
7
- */
8
- export declare function pack(options: PackOptions): Promise<void>;
9
- /**
10
- * Restore functions/package.json to its original file: reference.
11
- * Call after firebase deploy (e.g. in postdeploy script).
12
- */
13
- export declare function packRestore(options: PackOptions): Promise<void>;
14
- export {};
15
- //# sourceMappingURL=packDeploy.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"packDeploy.d.ts","sourceRoot":"","sources":["../../src/tools/packDeploy.ts"],"names":[],"mappings":"AASA,UAAU,WAAW;IACnB,YAAY,EAAE,MAAM,CAAA;CACrB;AAyBD;;;GAGG;AACH,wBAAsB,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAoD9D;AAED;;;GAGG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAyCrE"}
@@ -1,148 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.pack = pack;
37
- exports.packRestore = packRestore;
38
- const crypto_1 = require("crypto");
39
- const child_process_1 = require("child_process");
40
- const fs = __importStar(require("fs"));
41
- const path = __importStar(require("path"));
42
- // __dirname resolves symlinks, so when consumed via file: reference this points
43
- // to the real firebase-structured-logger directory, not node_modules.
44
- const packageRoot = path.join(__dirname, '..', '..');
45
- function readPackageJson(dir) {
46
- return JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf-8'));
47
- }
48
- function writePackageJson(dir, pkg) {
49
- fs.writeFileSync(path.join(dir, 'package.json'), JSON.stringify(pkg, null, 2) + '\n');
50
- }
51
- function findFslDep(pkg) {
52
- for (const field of ['dependencies', 'devDependencies']) {
53
- const deps = pkg[field];
54
- if (deps?.['firebase-structured-logger']) {
55
- return { field, ref: deps['firebase-structured-logger'] };
56
- }
57
- }
58
- return null;
59
- }
60
- /**
61
- * Build + pack firebase-structured-logger, copy tgz to functions/vendor/,
62
- * and patch functions/package.json to reference it. Call before firebase deploy.
63
- */
64
- async function pack(options) {
65
- const functionsDir = path.resolve(process.cwd(), options.functionsDir);
66
- const vendorDir = path.join(functionsDir, 'vendor');
67
- const manifestPath = path.join(vendorDir, '.fsl-restore.json');
68
- // 1. Build
69
- console.log('[fsl] Building firebase-structured-logger...');
70
- (0, child_process_1.execSync)('npm run build', { cwd: packageRoot, stdio: 'inherit' });
71
- // 2. Pack — use --json for reliable filename parsing
72
- console.log('[fsl] Packing...');
73
- const packOutput = (0, child_process_1.execSync)('npm pack --json', { cwd: packageRoot, encoding: 'utf-8' });
74
- const [{ filename: baseTgzFileName }] = JSON.parse(packOutput);
75
- const tgzSource = path.join(packageRoot, baseTgzFileName);
76
- // Use a content hash so the filename is stable for identical builds and
77
- // changes only when FSL itself changes — no calling-project release ID needed.
78
- const contentHash = (0, crypto_1.createHash)('sha256').update(fs.readFileSync(tgzSource)).digest('hex').slice(0, 8);
79
- const tgzFileName = baseTgzFileName.replace(/\.tgz$/, `-${contentHash}.tgz`);
80
- // 3. Copy to functions/vendor/ (remove any previous fsl tarballs first)
81
- fs.mkdirSync(vendorDir, { recursive: true });
82
- for (const f of fs.readdirSync(vendorDir)) {
83
- if (f.startsWith('firebase-structured-logger-') && f.endsWith('.tgz')) {
84
- fs.unlinkSync(path.join(vendorDir, f));
85
- }
86
- }
87
- const tgzDest = path.join(vendorDir, tgzFileName);
88
- fs.copyFileSync(tgzSource, tgzDest);
89
- fs.unlinkSync(tgzSource);
90
- console.log(`[fsl] Copied ${tgzFileName} → functions/vendor/`);
91
- // 4. Patch functions/package.json
92
- const pkg = readPackageJson(functionsDir);
93
- const existing = findFslDep(pkg);
94
- if (!existing) {
95
- console.error('[fsl] firebase-structured-logger not found in functions/package.json');
96
- process.exit(1);
97
- }
98
- const manifest = { originalRef: existing.ref, tgzFileName };
99
- fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2) + '\n');
100
- pkg[existing.field]['firebase-structured-logger'] =
101
- `file:./vendor/${tgzFileName}`;
102
- writePackageJson(functionsDir, pkg);
103
- // 5. npm install to lock in the tgz
104
- console.log('[fsl] Installing...');
105
- (0, child_process_1.execSync)('npm install', { cwd: functionsDir, stdio: 'inherit' });
106
- console.log('[fsl] Pack complete — ready to deploy.');
107
- }
108
- /**
109
- * Restore functions/package.json to its original file: reference.
110
- * Call after firebase deploy (e.g. in postdeploy script).
111
- */
112
- async function packRestore(options) {
113
- const functionsDir = path.resolve(process.cwd(), options.functionsDir);
114
- const vendorDir = path.join(functionsDir, 'vendor');
115
- const manifestPath = path.join(vendorDir, '.fsl-restore.json');
116
- if (!fs.existsSync(manifestPath)) {
117
- console.log('[fsl] No restore manifest found — nothing to restore.');
118
- return;
119
- }
120
- const { originalRef, tgzFileName } = JSON.parse(fs.readFileSync(manifestPath, 'utf-8'));
121
- // 1. Restore package.json — skip if originalRef is a file: path that no longer exists
122
- // (e.g. a previous vendor tarball that was cleaned up during pack).
123
- const pkg = readPackageJson(functionsDir);
124
- const existing = findFslDep(pkg);
125
- const refMatch = originalRef.match(/^file:(.+)$/);
126
- const refFilePath = refMatch ? path.resolve(functionsDir, refMatch[1]) : null;
127
- const refFileExists = refFilePath ? fs.existsSync(refFilePath) : true;
128
- if (existing) {
129
- if (refFileExists) {
130
- ;
131
- pkg[existing.field]['firebase-structured-logger'] = originalRef;
132
- writePackageJson(functionsDir, pkg);
133
- }
134
- else {
135
- console.log(`[fsl] Original ref (${originalRef}) no longer exists — keeping vendor tgz reference.`);
136
- }
137
- }
138
- // 2. Remove tgz + manifest — only remove tgz if we restored to a different ref
139
- const tgzPath = path.join(vendorDir, tgzFileName);
140
- if (refFileExists && fs.existsSync(tgzPath))
141
- fs.unlinkSync(tgzPath);
142
- fs.unlinkSync(manifestPath);
143
- // 3. npm install to restore
144
- console.log('[fsl] Restoring...');
145
- (0, child_process_1.execSync)('npm install', { cwd: functionsDir, stdio: 'inherit' });
146
- console.log('[fsl] Restore complete.');
147
- }
148
- //# sourceMappingURL=packDeploy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"packDeploy.js","sourceRoot":"","sources":["../../src/tools/packDeploy.ts"],"names":[],"mappings":";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