Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deadlock starting canvas, core_plugins/interpreter and kbn-interpreter in node 10 #26043

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ bower_components
/x-pack/coverage
/x-pack/build
/x-pack/plugins/**/__tests__/fixtures/**
/packages/kbn-interpreter/common/lib/grammar.js
/packages/kbn-interpreter/plugin
/packages/kbn-interpreter/src/common/lib/grammar.js
/x-pack/plugins/canvas/canvas_plugin
/x-pack/plugins/canvas/canvas_plugin_src/lib/flot-charts
**/*.js.snap
Expand Down
4 changes: 4 additions & 0 deletions packages/kbn-interpreter/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
common
plugin
public
server
7 changes: 6 additions & 1 deletion packages/kbn-interpreter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
"name": "@kbn/interpreter",
"version": "1.0.0",
"license": "Apache-2.0",
"main": "./index.js",
"scripts": {
"build": "node tasks/build.js",
"build": "babel src --out-dir . --ignore 'src/plugin/**/*' && node tasks/build.js",
"canvas:peg": "pegjs common/lib/grammar.peg",
"kbn:bootstrap": "yarn build"
},
"devDependencies": {
"@kbn/babel-preset": "1.0.0",
"babel-cli": "^6.26.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export const getServerRegistries = () => {

export const populateServerRegistries = types => {
if (called) {
console.log('function should only be called once per process');
return populatePromise;
}
called = true;
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-interpreter/tasks/webpack.plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

const path = require('path');

const sourceDir = path.resolve(__dirname, '../plugin_src');
const sourceDir = path.resolve(__dirname, '../src/plugin');
const buildDir = path.resolve(__dirname, '../plugin');

module.exports = {
Expand Down
5 changes: 3 additions & 2 deletions src/core_plugins/interpreter/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { routes } from './server/routes';
import { functionsRegistry } from '@kbn/interpreter/common/lib/functions_registry';
import { populateServerRegistries } from '@kbn/interpreter/server/server_registries';

export default function (server /*options*/) {
export default async function (server /*options*/) {
server.injectUiAppVars('canvas', () => {
const config = server.config();
const basePath = config.get('server.basePath');
Expand All @@ -37,5 +37,6 @@ export default function (server /*options*/) {
};
});

populateServerRegistries(['serverFunctions', 'types']).then(() => routes(server));
await populateServerRegistries(['serverFunctions', 'types']);
routes(server);
}
4 changes: 2 additions & 2 deletions src/optimize/base_optimizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ export default class BaseOptimizer {
},
{
test,
include: /[\/\\]node_modules[\/\\](x-pack|@kbn[\/\\]interpreter)[\/\\]/,
exclude: /[\/\\]node_modules[\/\\](x-pack|@kbn[\/\\]interpreter)[\/\\]node_modules[\/\\]/,
include: /[\/\\]node_modules[\/\\]x-pack[\/\\]/,
exclude: /[\/\\]node_modules[\/\\]x-pack[\/\\](.+?[\/\\])*node_modules[\/\\]/,

}
];
Expand Down
7 changes: 5 additions & 2 deletions src/setup_node_env/babel_register/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ var ignore = [
// https://github.com/elastic/kibana/issues/14800#issuecomment-366130268

// ignore paths matching `/node_modules/{a}/{b}`, unless `a`
// is `x-pack` or `@kbn/interpreter` and `b` is not `node_modules`
/\/node_modules\/(?!(x-pack\/|@kbn\/interpreter\/)(?!node_modules)([^\/]+))([^\/]+\/[^\/]+)/,
// is `x-pack` and `b` is not `node_modules`
/\/node_modules\/(?!x-pack\/(?!node_modules)([^\/]+))([^\/]+\/[^\/]+)/,

// ignore paths matching `/kbn-interpreter`
/\/kbn-interpreter\//,

// ignore paths matching `/canvas/canvas_plugin/{a}/{b}` unless
// `a` is `functions` and `b` is `server`
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/canvas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { resolve } from 'path';
import { pathsRegistry } from '@kbn/interpreter/common/lib/paths_registry';
import init from './init';
import { mappings } from './server/mappings';
import { CANVAS_APP } from './common/lib/constants';
import { CANVAS_APP } from './common/lib';
import { pluginPaths } from './plugin_paths';

export function canvas(kibana) {
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/canvas/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { functionsRegistry } from '@kbn/interpreter/common/lib/functions_registry';
import { getServerRegistries } from '@kbn/interpreter/server/server_registries';
import { populateServerRegistries } from '@kbn/interpreter/server/server_registries';
import { routes } from './server/routes';
import { commonFunctions } from './common/functions';
import { registerCanvasUsageCollector } from './server/usage';
Expand Down Expand Up @@ -34,6 +34,6 @@ export default async function(server /*options*/) {
loadSampleData(server);

// Do not initialize the app until the registries are populated
await getServerRegistries();
await populateServerRegistries(['serverFunctions', 'types']);
routes(server);
}