{"action":"closed","issue":{"url":"https://api.github.com/repos/colinbdclark/osc.js/issues/29","labels_url":"https://api.github.com/repos/colinbdclark/osc.js/issues/29/labels{/name}","comments_url":"https://api.github.com/repos/colinbdclark/osc.js/issues/29/comments","events_url":"https://api.github.com/repos/colinbdclark/osc.js/issues/29/events","html_url":"https://github.com/colinbdclark/osc.js/issues/29","id":101640457,"number":29,"title":"readBlob returns full bundle to not differentiating ArrayBuffer vs Buffer","user":{"login":"fde31","id":1119173,"avatar_url":"https://avatars.githubusercontent.com/u/1119173?v=3","gravatar_id":"","url":"https://api.github.com/users/fde31","html_url":"https://github.com/fde31","followers_url":"https://api.github.com/users/fde31/followers","following_url":"https://api.github.com/users/fde31/following{/other_user}","gists_url":"https://api.github.com/users/fde31/gists{/gist_id}","starred_url":"https://api.github.com/users/fde31/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fde31/subscriptions","organizations_url":"https://api.github.com/users/fde31/orgs","repos_url":"https://api.github.com/users/fde31/repos","events_url":"https://api.github.com/users/fde31/events{/privacy}","received_events_url":"https://api.github.com/users/fde31/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/colinbdclark/osc.js/milestones/9","html_url":"https://github.com/colinbdclark/osc.js/milestones/2.0.0","labels_url":"https://api.github.com/repos/colinbdclark/osc.js/milestones/9/labels","id":1336398,"number":9,"title":"2.0.0","description":null,"creator":{"login":"colinbdclark","id":558076,"avatar_url":"https://avatars.githubusercontent.com/u/558076?v=3","gravatar_id":"","url":"https://api.github.com/users/colinbdclark","html_url":"https://github.com/colinbdclark","followers_url":"https://api.github.com/users/colinbdclark/followers","following_url":"https://api.github.com/users/colinbdclark/following{/other_user}","gists_url":"https://api.github.com/users/colinbdclark/gists{/gist_id}","starred_url":"https://api.github.com/users/colinbdclark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/colinbdclark/subscriptions","organizations_url":"https://api.github.com/users/colinbdclark/orgs","repos_url":"https://api.github.com/users/colinbdclark/repos","events_url":"https://api.github.com/users/colinbdclark/events{/privacy}","received_events_url":"https://api.github.com/users/colinbdclark/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":2,"state":"open","created_at":"2015-10-03T21:25:31Z","updated_at":"2015-10-18T16:50:13Z","due_on":null,"closed_at":null},"comments":5,"created_at":"2015-08-18T12:03:43Z","updated_at":"2015-10-18T16:50:13Z","closed_at":"2015-10-18T16:50:13Z","body":"I was dealing with packets and nested bundles and noticed that the nested bundle is always equal the top level buffer. First I thought it's due to weird messages coming in but then came across a pretty nasty bug.\r\n\r\nIn https://github.com/colinbdclark/osc.js/blob/master/src/osc.js#L355 a new UInt8Array is created using the incoming buffer. On first glance this seems fine when referring to the TypedArray constructor as documented here (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#Syntax)\r\n\r\n> new TypedArray(buffer [, byteOffset [, length]]);\r\n>\r\n> When called with a buffer, and optionally a byteOffset and a length argument, a new typed array view is created that views the specified ArrayBuffer. The byteOffset and length parameters specify the memory range that will be exposed by the typed array view.  If both are omitted, all of buffer is viewed; if only length is omitted, the remainder of buffer is viewed.\r\n\r\nHowever this fails in a Node.js environment as the input is a Node Buffer instance and not an ArrayBuffer instance. Due to that the TypedArray constructor treats it as an Array and ignores the offset and length parameters.\r\n\r\nI committed a simple fix to my fork (see https://github.com/fde31/osc.js/commit/961da012a3aea2b1f8dcef9a78abaa4dda9addae) but maybe there is a more consistent way to fix this? On a first glimpse it seems like there might be 2-3 other situations where this might be a problem.\r\n\r\nAny thoughts?"}}