Skip to content

Commit

Permalink
fix(main): exception on startup
Browse files Browse the repository at this point in the history
Turns out sockets have a path length limit lol. Shorten the path by
changing "veonim-instance" prefix to "uivonim" (needed to be updated
anyways), and switch to pid instead of uuid cuz its process dependent
anyways.

Close #453, #593
  • Loading branch information
smolck committed Oct 31, 2023
1 parent 7704339 commit b7aa3ac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 0 additions & 3 deletions src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,6 @@ export const uuid = (): string =>
export const shell = (cmd: string, opts?: object): Promise<string> =>
new Promise((fin) => exec(cmd, opts, (_, out) => fin(out + '')))

export const getPipeName = (name: string) =>
join(tmpdir(), `${name}${uuid()}.sock`)

export const arrReplace = <T>(
arr: T[],
matcher: (val: T) => any,
Expand Down
8 changes: 5 additions & 3 deletions src/main/core/master-control.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { app } from 'electron'
import { asColor, merge, getPipeName } from '../../common/utils'
import { asColor, merge } from '../../common/utils'
import Worker, { Worker as WorkerType } from '../workers/messaging/worker'
import { Color, Highlight } from '../neovim/types'
import { ChildProcess, spawn } from 'child_process'
import InstanceApi from '../core/instance-api'
import * as neovim from 'neovim'
import { BrowserWindow } from 'electron'
import { resolve } from 'path'
import { join, resolve } from 'path'
import { tmpdir } from 'os'
import { pid } from 'process'

type RedrawFn = (m: any[]) => void
type ExitFn = (code: number) => void
Expand Down Expand Up @@ -83,7 +85,7 @@ const attachNvim = (nvimInstance: NvimInstance) => {
}

const createAndSetupNvimInstance = (useWsl: boolean, nvimBinary?: string) => {
const pipeName = getPipeName('veonim-instance')
const pipeName = join(tmpdir(), `uivonim-${pid}.sock`)
const proc = spawnNvimInstance(pipeName, useWsl, nvimBinary)

const nvimInstance = { proc, pipeName, attached: false }
Expand Down

0 comments on commit b7aa3ac

Please sign in to comment.