@adaptic/utils 0.0.980 → 0.0.981

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
@@ -5844,7 +5844,30 @@ async function getOrders$1(auth, params = {}) {
5844
5844
  return allOrders;
5845
5845
  }
5846
5846
  catch (error) {
5847
- getLogger().error("Error in getOrders:", error);
5847
+ const isTransient = isTransientNetworkError(error);
5848
+ const errMsg = error instanceof Error ? error.message : String(error);
5849
+ const logMeta = {
5850
+ source: "AlpacaLegacy.getOrders",
5851
+ error: errMsg,
5852
+ ...(isTransient
5853
+ ? {
5854
+ transient: true,
5855
+ recoveryHint: "Upstream caller should retry on next cycle",
5856
+ }
5857
+ : {}),
5858
+ };
5859
+ // Transient network errors (fetch timeouts, ECONNRESET) are
5860
+ // recoverable; log at WARN. Non-transient failures (4xx/auth)
5861
+ // stay at ERROR. Previous call also passed the raw Error as the
5862
+ // second argument, which Pino treats as context not as `err`,
5863
+ // producing empty `err` fields in production logs — fix by
5864
+ // serializing to an explicit string message.
5865
+ if (isTransient) {
5866
+ getLogger().warn(`Error in getOrders: ${errMsg}`, logMeta);
5867
+ }
5868
+ else {
5869
+ getLogger().error(`Error in getOrders: ${errMsg}`, logMeta);
5870
+ }
5848
5871
  throw error;
5849
5872
  }
5850
5873
  }