Skip to content

Commit

Permalink
[state] add a hard length limit that will start throwing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
spalger committed Apr 4, 2016
1 parent 55db90d commit 64699aa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/ui/public/config/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export default function configDefaultsProvider() {
description: 'The time in milliseconds which an information notification ' +
'will be displayed on-screen for. Setting to Infinity will disable.'
},
'warn:urlLength': {
'url:warnLength': {
value: 1900,
description: `
When the application url reaches this length we will start warning about
Expand All @@ -238,5 +238,9 @@ export default function configDefaultsProvider() {
If IE compatibility is not important this can probably be disabled (set to 0).
`,
},
'url:limit': {
value: 2082,
description: 'When the application url reaches this length we will start to aggressively fail.',
},
};
};
14 changes: 12 additions & 2 deletions src/ui/public/state_management/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,18 @@ export default function StateProvider(Private, $rootScope, $location, config) {
$location.search(search);
}

const warnLength = config.get('warn:urlLength');
if (warnLength && $location.absUrl().length > warnLength) {
const urlLength = $location.absUrl().length;
const warnLength = config.get('url:warnLength');
const failLength = config.get('url:limit');

if (failLength && urlLength >= failLength) {
throw new TypeError(`
The URL has gotten too big and kibana can no longer
continue. Please refresh to return to your previous state.
`);
}

if (warnLength && urlLength >= warnLength) {
notify.warning(`
The URL has gotten big and may cause Kibana
to stop working. Please simplify the data on screen.
Expand Down

0 comments on commit 64699aa

Please sign in to comment.