mirror of
https://github.com/Kong/insomnia.git
synced 2026-08-04 03:42:20 -04:00
address root cause
This commit is contained in:
@@ -19,7 +19,7 @@ export async function sendRequest(
|
||||
try {
|
||||
const requestOptions = requestToCurlOptions(request, settings);
|
||||
const nodejsCurlRequest =
|
||||
process.type === 'renderer'
|
||||
typeof window !== 'undefined' && window.bridge != null
|
||||
? window.bridge.curlRequest
|
||||
: (await import('insomnia/src/main/network/libcurl-promise')).curlRequest;
|
||||
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
// NOTE: this file should not be imported by electron renderer because node-libcurl is not-context-aware
|
||||
// Related issue https://github.com/JCMais/node-libcurl/issues/155
|
||||
import { invariant } from '../../utils/invariant';
|
||||
invariant(process.type !== 'renderer', 'Native abstractions for Nodejs module unavailable in renderer');
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import type { Readable, Writable } from 'node:stream';
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
if (process.type === 'renderer') {
|
||||
throw new Error('multipart.ts unavailable in renderer');
|
||||
}
|
||||
|
||||
import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
|
||||
@@ -4,7 +4,7 @@ import { invariant } from 'insomnia/src/utils/invariant';
|
||||
import { platform } from 'insomnia-data/common';
|
||||
|
||||
// TODO: consider how this would work in a webworker context
|
||||
const isRenderer = process.type === 'renderer';
|
||||
const isRenderer = typeof window !== 'undefined';
|
||||
|
||||
export const init = (renderPurpose: RenderPurpose = 'general'): { app: AppContext } => ({
|
||||
app: {
|
||||
|
||||
@@ -58,7 +58,7 @@ export function init(): {
|
||||
const settingFollowRedirects = settings?.followRedirects ? 'on' : 'off';
|
||||
const { request: originRequest, caCertficatePath = null } = options;
|
||||
const curlRequest =
|
||||
process.type === 'renderer' || process.type === 'worker'
|
||||
typeof window !== 'undefined' && window.main != null
|
||||
? window.main.curlRequest
|
||||
: // when exeucted in Inso;
|
||||
(await import('../../main/network/libcurl-promise')).curlRequest;
|
||||
|
||||
@@ -129,7 +129,8 @@ export async function getPlugins(force = false): Promise<Plugin[]> {
|
||||
|
||||
// Make sure the default directories exist
|
||||
const pluginPath = path.resolve(
|
||||
process.env['INSOMNIA_DATA_PATH'] || (process.type === 'renderer' ? window : electron).app.getPath('userData'),
|
||||
process.env['INSOMNIA_DATA_PATH'] ||
|
||||
(typeof window !== 'undefined' && window.app != null ? window : electron).app.getPath('userData'),
|
||||
'plugins',
|
||||
);
|
||||
|
||||
@@ -299,7 +300,7 @@ export function getPluginCommonContext({
|
||||
...pluginNetwork.init(),
|
||||
util: {
|
||||
openInBrowser: async (url: string) =>
|
||||
process.type === 'renderer' || process.type === 'worker'
|
||||
typeof window !== 'undefined' && window.main != null
|
||||
? window.main.openInBrowser(url)
|
||||
: electron.shell.openExternal(url),
|
||||
models: {
|
||||
|
||||
@@ -15,10 +15,6 @@ export default defineConfig(({ mode }) => {
|
||||
'__IS_RENDERER__': JSON.stringify(true),
|
||||
'process.env.NODE_ENV': JSON.stringify(mode),
|
||||
'process.env.INSOMNIA_ENV': JSON.stringify(mode),
|
||||
// Only apply in production builds: Rollup does text substitution (safe).
|
||||
// In dev mode Vite uses runtime assignment via env.mjs, which throws
|
||||
// TypeError because process.type is read-only in Electron's renderer process.
|
||||
...(!__DEV__ ? { 'process.type': JSON.stringify('renderer') } : {}),
|
||||
},
|
||||
server: {
|
||||
port: pkg.dev['dev-server-port'],
|
||||
|
||||
Reference in New Issue
Block a user