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

__DEV__ logic is now ‘NODE_ENV is not production’ #2907

Merged
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
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),
);
Copy link
Contributor

@mcintyre94 mcintyre94 Jul 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI error seems to be related to the changes in this file - are they intended to be in this PR at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. This change was supposed to fix a test failure owing to the fact that error 123 doesn’t exist.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, it’s lint I left behind.

Maybe I’ll try to do this properly with mocks this time.

});
it('throws errors when the connection fails to construct', async () => {
expect.assertions(1);
Expand Down