localForage / localForage/localForage

IE 11 - Keys greater in length than 889 characters are truncated.

Open
#444 11 comments 0 reactions 0 assignees View on GitHub
blocked bug help wanted
Dominant language
JavaScript
Stars
25.8k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

Browser: IE 11
Version: 11.0.9600.17843, Update Versions: 11.0.20 (KB3058515)

Observed Behavior:
If a key of length greater than 888 characters is set in IE 11, anything beyond the 889th character is ignored. This means that if I have two keys of 900 characters in length, and only the last 10 characters are different, the last value set will be the one returned for either key.

Expected Behavior:
Key length should not affect behavior. Different keys of 900 characters in length should be able to map to different values even if only the last character is different.

To reproduce in console:

``` js
function testLocalForageKeyLength(length) {
// Clear localforage
localforage.clear();

// init keys and values
var key1 = new Array(length+1).join('1'),
key2 = key1 + '2',// Key2 is 1 character longer than key1.
val1 = '1',
val2 = '2';
localforage.setItem(key1, val1).then(function(){
localforage.setItem(key2, val2).then(function(){
localforage.getItem(key1).then(function(v1){
localforage.getItem(key2).then(function(v2) {
var err = false;
if (v1 === v2) {
err = true;
console.error("Failed asserting that values are different.");
}
if (v1 !== val1) {
err = true;
console.error("Failed asserting that returned value for key1 is equal to set value for key1.")
}
if (v2 !== val2) {
err = true;
console.error("Failed asserting that returned value for key2 is equal to set value for key2.")
}
if (!err) {
console.log("Succeeded asserting that values are different.");
}
console.log("key1 length: " + key1.length + " key2 length: " + key2.length + " key1 value returned: " + v1 + " key2 value returned: " + v2);
})
});
});
});
}

testLocalForageKeyLength(10);
// Wait for return of each test before proceeding...
testLocalForageKeyLength(100);
testLocalForageKeyLength(888);
testLocalForageKeyLength(889);
```

Console Output:

```
testLocalForageKeyLength(10);
Succeeded asserting that values are different.
key1 length: 10 key2 length: 11 key1 value returned: 1 key2 value returned: 2

testLocalForageKeyLength(100);
Succeeded asserting that values are different.
key1 length: 100 key2 length: 101 key1 value returned: 1 key2 value returned: 2

testLocalForageKeyLength(888);
Succeeded asserting that values are different.
key1 length: 888 key2 length: 889 key1 value returned: 1 key2 value returned: 2

testLocalForageKeyLength(889);
Failed asserting that values are different.
Failed asserting that returned value for key1 is equal to set value for key1.
key1 length: 889 key2 length: 890 key1 value returned: 2 key2 value returned: 2
```

Contributor guide

Open the contributing guide

Research direction

Start with the IE 11 console reproduction in the issue, testing key lengths around 888 and 889 characters through localForage. Trace the storage driver behavior for long keys and verify that distinct keys retain distinct values after setItem and getItem; the issue is done when the reproduction succeeds in IE 11.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.