Skip to content

Commit

Permalink
[browserslist] remove user-agent sniffing for IE support hint (#74464)
Browse files Browse the repository at this point in the history
Co-authored-by: spalger <[email protected]>
  • Loading branch information
Spencer and spalger authored Aug 6, 2020
1 parent dad5c72 commit 79713b9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 69 deletions.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@
"bluebird": "3.5.5",
"boom": "^7.2.0",
"brace": "0.11.1",
"browserslist-useragent": "^3.0.2",
"cache-loader": "^4.1.0",
"chalk": "^2.4.2",
"check-disk-space": "^2.1.0",
Expand Down Expand Up @@ -319,7 +318,6 @@
"@types/babel__core": "^7.1.2",
"@types/bluebird": "^3.1.1",
"@types/boom": "^7.2.0",
"@types/browserslist-useragent": "^3.0.0",
"@types/chance": "^1.0.0",
"@types/cheerio": "^0.22.10",
"@types/chromedriver": "^81.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-optimizer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ The [Webpack config][WebpackConfig] is designed to provide the majority of what

Source maps are enabled except when building the distributable. They show the code actually being executed by the browser to strike a balance between debuggability and performance. They are not configurable at this time but will be configurable once we have a developer configuration solution that doesn't rely on the server (see [#55656](https://github.com/elastic/kibana/issues/55656)).

### IE Support
### Browser Support

To make front-end code easier to debug the optimizer uses the `BROWSERSLIST_ENV=dev` environment variable (by default) to build JS and CSS that is compatible with modern browsers. In order to support older browsers like IE in development you will need to specify the `BROWSERSLIST_ENV=production` environment variable or build a distributable for testing.
To make front-end code easier to debug the optimizer uses the `BROWSERSLIST_ENV=dev` environment variable (by default) to build JS and CSS that is compatible with modern browsers. In order to support all browsers that we support with the distributable you will need to specify the `BROWSERSLIST_ENV=production` environment variable or build a distributable for testing.

## Running the optimizer

Expand Down
36 changes: 1 addition & 35 deletions src/core/server/http/base_path_proxy_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ import { Agent as HttpsAgent, ServerOptions as TlsOptions } from 'https';

import apm from 'elastic-apm-node';
import { ByteSizeValue } from '@kbn/config-schema';
import { Server, Request, ResponseToolkit } from 'hapi';
import { Server, Request } from 'hapi';
import HapiProxy from 'h2o2';
import { sampleSize } from 'lodash';
import BrowserslistUserAgent from 'browserslist-useragent';
import * as Rx from 'rxjs';
import { take } from 'rxjs/operators';

Expand All @@ -41,34 +40,6 @@ export interface BasePathProxyServerOptions {
delayUntil: () => Rx.Observable<void>;
}

// Before we proxy request to a target port we may want to wait until some
// condition is met (e.g. until target listener is ready).
const checkForBrowserCompat = (log: Logger) => async (request: Request, h: ResponseToolkit) => {
if (!request.headers['user-agent'] || process.env.BROWSERSLIST_ENV === 'production') {
return h.continue;
}

const matches = BrowserslistUserAgent.matchesUA(request.headers['user-agent'], {
env: 'dev',
allowHigherVersions: true,
ignoreMinor: true,
ignorePath: true,
});

if (!matches) {
log.warn(`
Request with user-agent [${request.headers['user-agent']}]
seems like it is coming from a browser that is not supported by the dev browserlist.
Please run Kibana with the environment variable BROWSERSLIST_ENV=production to enable
support for all production browsers (like IE).
`);
}

return h.continue;
};

export class BasePathProxyServer {
private server?: Server;
private httpsAgent?: HttpsAgent;
Expand Down Expand Up @@ -155,9 +126,6 @@ export class BasePathProxyServer {
},
method: 'GET',
path: '/',
options: {
pre: [checkForBrowserCompat(this.log)],
},
});

this.server.route({
Expand All @@ -175,7 +143,6 @@ export class BasePathProxyServer {
method: '*',
options: {
pre: [
checkForBrowserCompat(this.log),
// Before we proxy request to a target port we may want to wait until some
// condition is met (e.g. until target listener is ready).
async (request, responseToolkit) => {
Expand Down Expand Up @@ -210,7 +177,6 @@ export class BasePathProxyServer {
method: '*',
options: {
pre: [
checkForBrowserCompat(this.log),
// Before we proxy request to a target port we may want to wait until some
// condition is met (e.g. until target listener is ready).
async (request, responseToolkit) => {
Expand Down
38 changes: 8 additions & 30 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4306,11 +4306,6 @@
resolved "https://registry.yarnpkg.com/@types/boom/-/boom-7.2.0.tgz#19c36cbb5811a7493f0f2e37f31d42b28df1abc1"
integrity sha512-HonbGsHFbskh9zRAzA6tabcw18mCOsSEOL2ibGAuVqk6e7nElcRmWO5L4UfIHpDbWBWw+eZYFdsQ1+MEGgpcVA==

"@types/browserslist-useragent@^3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@types/browserslist-useragent/-/browserslist-useragent-3.0.0.tgz#d425c9818182ce71ce53866798cee9c7d41d6e53"
integrity sha512-ZBvKzg3yyWNYEkwxAzdmUzp27sFvw+1m080/+2lwrt+eltNefn1f4fnpMyrjOla31p8zLleCYqQXw+3EETfn0w==

"@types/cacheable-request@^6.0.1":
version "6.0.1"
resolved "https://registry.yarnpkg.com/@types/cacheable-request/-/cacheable-request-6.0.1.tgz#5d22f3dded1fd3a84c0bbeb5039a7419c2c91976"
Expand Down Expand Up @@ -8601,15 +8596,6 @@ browserify-zlib@^0.2.0:
dependencies:
pako "~1.0.5"

browserslist-useragent@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/browserslist-useragent/-/browserslist-useragent-3.0.2.tgz#f0e209b2742baa5de0e451b52e678e8b4402617c"
integrity sha512-/UPzK9xZnk5mwwWx4wcuBKAKx/mD3MNY8sUuZ2NPqnr4RVFWZogX+8mOP0cQEYo8j78sHk0hiDNaVXZ1U3hM9A==
dependencies:
browserslist "^4.6.6"
semver "^6.3.0"
useragent "^2.3.0"

[email protected]:
version "4.6.6"
resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.6.6.tgz#6e4bf467cde520bc9dbdf3747dafa03531cec453"
Expand All @@ -8629,7 +8615,7 @@ browserslist@^4.12.0:
node-releases "^1.1.53"
pkg-up "^2.0.0"

browserslist@^4.6.6, browserslist@^4.8.3:
browserslist@^4.8.3:
version "4.8.5"
resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.8.5.tgz#691af4e327ac877b25e7a3f7ee869c4ef36cdea3"
integrity sha512-4LMHuicxkabIB+n9874jZX/az1IaZ5a+EUuvD7KFOu9x/Bd5YHyO0DIz2ls/Kl8g0ItS4X/ilEgf4T1Br0lgSg==
Expand Down Expand Up @@ -29564,13 +29550,6 @@ [email protected]:
dependencies:
os-tmpdir "~1.0.1"

[email protected], tmp@^0.0.33:
version "0.0.33"
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9"
integrity sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==
dependencies:
os-tmpdir "~1.0.2"

[email protected], tmp@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.1.0.tgz#ee434a4e22543082e294ba6201dcc6eafefa2877"
Expand All @@ -29585,6 +29564,13 @@ tmp@^0.0.29:
dependencies:
os-tmpdir "~1.0.1"

tmp@^0.0.33:
version "0.0.33"
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9"
integrity sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==
dependencies:
os-tmpdir "~1.0.2"

[email protected]:
version "1.0.4"
resolved "https://registry.yarnpkg.com/tmpl/-/tmpl-1.0.4.tgz#23640dd7b42d00433911140820e5cf440e521dd1"
Expand Down Expand Up @@ -30711,14 +30697,6 @@ user-home@^2.0.0:
dependencies:
os-homedir "^1.0.0"

useragent@^2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/useragent/-/useragent-2.3.0.tgz#217f943ad540cb2128658ab23fc960f6a88c9972"
integrity sha512-4AoH4pxuSvHCjqLO04sU6U/uE65BYza8l/KKBS0b0hnUPWi+cQ2BpeTEwejCSx9SPV5/U03nniDTrWx5NrmKdw==
dependencies:
lru-cache "4.1.x"
tmp "0.0.x"

utif@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/utif/-/utif-2.0.1.tgz#9e1582d9bbd20011a6588548ed3266298e711759"
Expand Down

0 comments on commit 79713b9

Please sign in to comment.