Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
__DEV__ logic is now ‘NODE_ENV is not production’
Browse files Browse the repository at this point in the history
  • Loading branch information
steveluscher committed Jul 3, 2024
1 parent 50b5da1 commit b9f7231
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
10 changes: 10 additions & 0 deletions .changeset/rich-eggs-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@solana/errors': patch
'@solana/rpc': patch
'@solana/rpc-subscriptions': patch
'@solana/rpc-subscriptions-transport-websocket': patch
'@solana/rpc-transport-http': patch
'@solana/webcrypto-ed25519-polyfill': patch
---

`__DEV__` mode will now be the default if you don't set `process.env.NODE_ENV` at all. This means fewer people ‘accidentally’ finding themselves in production mode with minified error messages.
4 changes: 2 additions & 2 deletions packages/build-scripts/dev-flag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ function replaceDev(source: string): string {
const root = j(source);
root.find(j.Identifier, { name: '__DEV__' }).replaceWith(() =>
j.binaryExpression(
'===',
'!==',
j.memberExpression(
j.memberExpression(j.identifier('process'), j.identifier('env')),
j.identifier('NODE_ENV'),
),
j.stringLiteral('development'),
j.stringLiteral('production'),
),
);
return root.toSource();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
SOLANA_ERROR__RPC_SUBSCRIPTIONS__CANNOT_CREATE_SUBSCRIPTION_REQUEST,
SOLANA_ERROR__RPC_SUBSCRIPTIONS__EXPECTED_SERVER_SUBSCRIPTION_ID,
SolanaError,
SolanaErrorCode,
} from '@solana/errors';
import { createRpcMessage } from '@solana/rpc-spec-types';

Expand Down Expand Up @@ -263,12 +262,14 @@ describe('JSON-RPC 2.0 Subscriptions', () => {
expect.assertions(1);
iterable.mockImplementation(async function* () {
yield Promise.resolve({
error: { code: 123, message: 'o no' },
error: { code: SOLANA_ERROR__RPC_SUBSCRIPTIONS__EXPECTED_SERVER_SUBSCRIPTION_ID },
id: 0,
});
});
const subscribePromise = rpc.thingNotifications().subscribe({ abortSignal: new AbortController().signal });
await expect(subscribePromise).rejects.toThrow(new SolanaError(123 as SolanaErrorCode, undefined));
await expect(subscribePromise).rejects.toThrow(
new SolanaError(SOLANA_ERROR__RPC_SUBSCRIPTIONS__EXPECTED_SERVER_SUBSCRIPTION_ID),
);
});
it('throws errors when the connection fails to construct', async () => {
expect.assertions(1);
Expand Down

0 comments on commit b9f7231

Please sign in to comment.