Skip to content

Commit

Permalink
Fix plugin runtime port
Browse files Browse the repository at this point in the history
  • Loading branch information
gschier committed Jan 21, 2025
1 parent c58bfeb commit 5d505d1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions packages/plugin-runtime/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { EventChannel } from './EventChannel';
import { PluginHandle } from './PluginHandle';
import WebSocket from 'ws';

const port = process.env.YAAK_PLUGIN_SERVER_PORT || '9442';
const port = process.env.PORT;
if (!port) {
throw new Error('Plugin runtime missing PORT')
}

const events = new EventChannel();
const plugins: Record<string, PluginHandle> = {};
Expand All @@ -17,9 +20,9 @@ ws.on('message', async (e: Buffer) => {
console.log('Failed to handle incoming plugin event', err);
}
});
ws.on('open', (e) => console.log('Plugin runtime connected to websocket', e));
ws.on('error', (e) => console.error('Plugin runtime websocket error', e));
ws.on('close', (e) => console.log('Plugin runtime websocket closed', e));
ws.on('open', () => console.log('Plugin runtime connected to websocket'));
ws.on('error', (err: any) => console.error('Plugin runtime websocket error', err));
ws.on('close', (code: number) => console.log('Plugin runtime websocket closed', code));

// Listen for incoming events from plugins
events.listen((e) => {
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/yaak-plugins/src/nodejs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub async fn start_nodejs_plugin_runtime<R: Runtime>(
let cmd = app
.shell()
.sidecar("yaaknode")?
.env("YAAK_PLUGIN_RUNTIME_PORT", addr.port().to_string())
.env("PORT", addr.port().to_string())
.args(&[&plugin_runtime_main]);

let (mut child_rx, child) = cmd.spawn()?;
Expand Down

0 comments on commit 5d505d1

Please sign in to comment.