Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes issue with process undefined #516

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/healthy-tools-accept.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@osdk/client": patch
---

Makes defining process.env.NODE_ENV optional
2 changes: 1 addition & 1 deletion packages/client/src/object/convertWireToOsdkObjects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ function isConforming(
) {
for (const propName of propsToCheck) {
if (def.properties[propName].nullable === false && obj[propName] == null) {
if (process.env.NODE_ENV !== "production") {
if (process?.env?.NODE_ENV !== "production") {
client.logger?.debug(
{
obj: {
Expand Down
20 changes: 10 additions & 10 deletions packages/client/src/objectSet/ObjectSetListenerWebsocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export class ObjectSetListenerWebsocket {
* @returns
*/
async #initiateSubscribe(sub: Subscription<any>) {
if (process.env.NODE_ENV !== "production") {
if (process?.env?.NODE_ENV !== "production") {
this.#logger?.trace("#initiateSubscribe()");
}
if (sub.expiry) {
Expand Down Expand Up @@ -278,7 +278,7 @@ export class ObjectSetListenerWebsocket {
}

#sendSubscribeMessage() {
if (process.env.NODE_ENV !== "production") {
if (process?.env?.NODE_ENV !== "production") {
this.#logger?.trace("#sendSubscribeMessage()");
}
// If two calls to `.subscribe()` happen at once (or if the connection is reset),
Expand All @@ -287,7 +287,7 @@ export class ObjectSetListenerWebsocket {
const readySubs = [...this.#subscriptions.values()].filter(isReady);

if (readySubs.length === 0) {
if (process.env.NODE_ENV !== "production") {
if (process?.env?.NODE_ENV !== "production") {
this.#logger?.trace(
"#sendSubscribeMessage(): aborting due to no ready subscriptions",
);
Expand Down Expand Up @@ -316,7 +316,7 @@ export class ObjectSetListenerWebsocket {
})),
};

if (process.env.NODE_ENV !== "production") {
if (process?.env?.NODE_ENV !== "production") {
this.#logger?.trace(
{ payload: subscribe },
"sending subscribe message",
Expand All @@ -327,7 +327,7 @@ export class ObjectSetListenerWebsocket {
}

#expire(sub: Subscription<any>) {
if (process.env.NODE_ENV !== "production") {
if (process?.env?.NODE_ENV !== "production") {
this.#logger?.trace({ subscription: sub }, "#expire()");
}
// the temporary ObjectSet has expired, we should re-subscribe which will cause the
Expand Down Expand Up @@ -403,7 +403,7 @@ export class ObjectSetListenerWebsocket {

// we again may have lost the race after our minimum backoff time
if (this.#ws == null) {
if (process.env.NODE_ENV !== "production") {
if (process?.env?.NODE_ENV !== "production") {
this.#logger?.trace("Creating websocket");
}
this.#ws = new WebSocket(url, [`Bearer-${token}`]);
Expand Down Expand Up @@ -449,7 +449,7 @@ export class ObjectSetListenerWebsocket {
| StreamMessage
| Message;

if (process.env.NODE_ENV !== "production") {
if (process?.env?.NODE_ENV !== "production") {
this.#logger?.trace({ payload: data }, "received message from ws");
}

Expand Down Expand Up @@ -543,7 +543,7 @@ export class ObjectSetListenerWebsocket {
const shouldFireOutOfDate = sub.status === "expired"
|| sub.status === "reconnecting";

if (process.env.NODE_ENV !== "production") {
if (process?.env?.NODE_ENV !== "production") {
this.#logger?.trace({ shouldFireOutOfDate }, "success");
}

Expand Down Expand Up @@ -572,7 +572,7 @@ export class ObjectSetListenerWebsocket {
}

#onClose = (event: WebSocket.CloseEvent) => {
if (process.env.NODE_ENV !== "production") {
if (process?.env?.NODE_ENV !== "production") {
this.#logger?.trace({ event }, "Received close event from ws", event);
}
// TODO we should probably throttle this so we don't abuse the backend
Expand Down Expand Up @@ -621,7 +621,7 @@ export class ObjectSetListenerWebsocket {

// if we have any listeners that are still depending on us, go ahead and reopen the websocket
if (this.#subscriptions.size > 0) {
if (process.env.NODE_ENV !== "production") {
if (process?.env?.NODE_ENV !== "production") {
for (const s of this.#subscriptions.values()) {
invariant(
s.status !== "done" && s.status !== "error",
Expand Down
2 changes: 1 addition & 1 deletion packages/legacy-client/src/client/addCause.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

export function addCause(e: Error, cause: any) {
if (process.env.NODE_ENV !== "production") {
if (process?.env?.NODE_ENV !== "production") {
// In case someone is debugging on an older browser or the `.cause` assignment trick
// does not work in certain environments, we log the cause to the console to aid debugging.
// eslint-disable-next-line no-console
Expand Down