@zapier/kitcore 0.10.0 → 0.10.1

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/dist/index.mjs CHANGED
@@ -168,13 +168,34 @@ function buildRegistry({
168
168
  }
169
169
 
170
170
  // src/utils/build-hooks.ts
171
- function composeVoid(existing, added) {
172
- if (!existing) return added;
173
- if (!added) return existing;
174
- return (ctx) => {
175
- existing(ctx);
176
- added(ctx);
171
+ var isolated = /* @__PURE__ */ new WeakSet();
172
+ function isolate(observer) {
173
+ if (!observer) return void 0;
174
+ if (isolated.has(observer)) return observer;
175
+ const wrapped = (ctx) => {
176
+ try {
177
+ observer(ctx);
178
+ } catch (error) {
179
+ console.error(
180
+ "[core] A method-lifecycle observer threw and was ignored. Observers are fire-and-forget and must not throw.",
181
+ error
182
+ );
183
+ }
177
184
  };
185
+ isolated.add(wrapped);
186
+ return wrapped;
187
+ }
188
+ function composeVoid(existing, added) {
189
+ const wrappedExisting = isolate(existing);
190
+ const wrappedAdded = isolate(added);
191
+ if (!wrappedExisting) return wrappedAdded;
192
+ if (!wrappedAdded) return wrappedExisting;
193
+ const composed = (ctx) => {
194
+ wrappedExisting(ctx);
195
+ wrappedAdded(ctx);
196
+ };
197
+ isolated.add(composed);
198
+ return composed;
178
199
  }
179
200
  function buildHooks(existing, added) {
180
201
  const result = {};
@@ -925,24 +946,27 @@ function createPaginatedFunction(coreFn, options) {
925
946
  return result.value;
926
947
  });
927
948
  if (hooks?.onMethodEnd) {
928
- firstPagePromise.then(() => {
929
- hooks.onMethodEnd({
930
- methodName: functionName,
931
- args,
932
- isPaginated: true,
933
- depth,
934
- durationMs: Date.now() - startTime
935
- });
936
- }).catch((error) => {
937
- hooks.onMethodEnd({
938
- methodName: functionName,
939
- args,
940
- isPaginated: true,
941
- depth,
942
- durationMs: Date.now() - startTime,
943
- error: error instanceof Error ? error : new Error(String(error))
944
- });
945
- });
949
+ firstPagePromise.then(
950
+ () => {
951
+ hooks.onMethodEnd({
952
+ methodName: functionName,
953
+ args,
954
+ isPaginated: true,
955
+ depth,
956
+ durationMs: Date.now() - startTime
957
+ });
958
+ },
959
+ (error) => {
960
+ hooks.onMethodEnd({
961
+ methodName: functionName,
962
+ args,
963
+ isPaginated: true,
964
+ depth,
965
+ durationMs: Date.now() - startTime,
966
+ error: error instanceof Error ? error : new Error(String(error))
967
+ });
968
+ }
969
+ );
946
970
  }
947
971
  const pageStream = async function* () {
948
972
  yield await firstPagePromise;