Skip to content

Commit

Permalink
Fix missing react import in context
Browse files Browse the repository at this point in the history
  • Loading branch information
apteryxxyz committed Jul 1, 2024
1 parent dbf923b commit bcfd4be
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/core/src/client/context.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use client';

import type React from 'react';
// biome-ignore lint/style/useImportType: <explanation>
import React from 'react';
import { createContext, useContext, useEffect, useMemo } from 'react';

export const WebSocketContext = createContext<WebSocket | null>(null);
Expand Down
7 changes: 5 additions & 2 deletions packages/core/src/server/helpers/persistent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ function mainProcessOnly(fnName: string) {
if (!meta.isMainProcess) {
throw new Error(
`[next-ws] Attempt to invoke '${fnName}' outside the main process.
You may be attempting to interact with the WebSocket server outside of a SOCKET handler. This is likely to fail in production environments, as Next.js employs a worker process for routing in production, which do not have access to the WebSocket server on the main process.`,
You may be attempting to interact with the WebSocket server outside of a SOCKET handler. This will fail in production, as Next.js employs a worker process for routing, which do not have access to the WebSocket server on the main process.
You can resolve this by using a custom server.`,
);
} else if (!meta.isCustomServer) {
logger.warnOnce(
`[next-ws] Caution: The function '${fnName}' was invoked without a custom server.
This could lead to unintended behaviour, especially if you're attempting to interact with the WebSocket server outside of a SOCKET handler. Please note, while such configurations might function during development, they are likely to fail in production environments. This is because Next.js employs a worker process for routing in production, which do not have access to the WebSocket server on the main process.`,
This could lead to unintended behaviour, especially if you're attempting to interact with the WebSocket server outside of a SOCKET handler.
Please note, while such configurations might function during development, they will fail in production. This is because Next.js employs a worker process for routing in production, which do not have access to the WebSocket server on the main process.
You can resolve this by using a custom server.`,
);
}
}
Expand Down

0 comments on commit bcfd4be

Please sign in to comment.