Skip to content

Commit

Permalink
Merge pull request #22575 from storybookjs/norbert/serverchannel-mana…
Browse files Browse the repository at this point in the history
…ger-fix

only connect to serverChannel in development mode
  • Loading branch information
ndelangen authored and shilman committed May 22, 2023
1 parent 5c73a4c commit 2aef693
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion code/lib/builder-manager/src/utils/template.ts
Expand Up @@ -58,7 +58,7 @@ export const renderHTML = async (
refs: Promise<Record<string, Ref>>,
logLevel: Promise<string>,
docsOptions: Promise<DocsOptions>,
{ versionCheck, releaseNotesData, previewUrl, serverChannelUrl, configType }: Options
{ versionCheck, releaseNotesData, previewUrl, configType }: Options
) => {
const customHeadRef = await customHead;
const titleRef = await title;
Expand Down
8 changes: 4 additions & 4 deletions code/lib/builder-vite/src/codegen-set-addon-channel.ts
@@ -1,16 +1,16 @@
export async function generateAddonSetupCode() {
return `
import { global } from '@storybook/global';
import { createChannel as createPostMessageChannel } from '@storybook/channel-postmessage';
import { createChannel as createWebSocketChannel } from '@storybook/channel-websocket';
import { addons } from '@storybook/preview-api';
const channel = createPostMessageChannel({ page: 'preview' });
addons.setChannel(channel);
window.__STORYBOOK_ADDONS_CHANNEL__ = channel;
const { SERVER_CHANNEL_URL } = globalThis;
if (SERVER_CHANNEL_URL) {
const serverChannel = createWebSocketChannel({ url: SERVER_CHANNEL_URL });
if (global.CONFIG_TYPE === 'DEVELOPMENT'){
const serverChannel = createWebSocketChannel({});
addons.setServerChannel(serverChannel);
window.__STORYBOOK_SERVER_CHANNEL__ = serverChannel;
}
Expand Down
Expand Up @@ -14,8 +14,8 @@ const getProjectAnnotations = () =>
const channel = createPostMessageChannel({ page: 'preview' });
addons.setChannel(channel);

if (SERVER_CHANNEL_URL) {
const serverChannel = createWebSocketChannel({ url: SERVER_CHANNEL_URL, });
if (global.CONFIG_TYPE === 'DEVELOPMENT'){
const serverChannel = createWebSocketChannel({});
addons.setServerChannel(serverChannel);
window.__STORYBOOK_SERVER_CHANNEL__ = serverChannel;
}
Expand Down
6 changes: 3 additions & 3 deletions code/ui/manager/src/runtime.ts
Expand Up @@ -13,7 +13,7 @@ import { renderStorybookUI } from './index';
import { values } from './globals/runtime';
import { Keys } from './globals/types';

const { FEATURES, SERVER_CHANNEL_URL } = global;
const { FEATURES, CONFIG_TYPE } = global;

class ReactProvider extends Provider {
private addons: AddonStore;
Expand All @@ -35,8 +35,8 @@ class ReactProvider extends Provider {
this.addons = addons;
this.channel = postMessageChannel;

if (FEATURES?.storyStoreV7 && SERVER_CHANNEL_URL) {
const serverChannel = webSocket.createChannel({ url: SERVER_CHANNEL_URL });
if (FEATURES?.storyStoreV7 && CONFIG_TYPE === 'DEVELOPMENT') {
const serverChannel = webSocket.createChannel({});
this.serverChannel = serverChannel;
addons.setServerChannel(this.serverChannel);
}
Expand Down

0 comments on commit 2aef693

Please sign in to comment.