Static files with precompress = true returns wrong data
See original GitHub issueActual behavior (the bug)
Static files serving a .js
file returns wrong data when precompress = true
.
Video of the behavior: https://www.loom.com/share/9066ccc851ba471b85b437ae39762fbc
The video begins with the bad output, then shows good output after doing precompress = false
and rebuilding/refreshing.
Screenshot:
Expected behavior
the data in asdf.js
is served correctly.
To Reproduce
Static files config:
config.staticFiles.add(staticFiles -> {
staticFiles.hostedPath = "/";
staticFiles.directory = "/next/";
staticFiles.location = Location.CLASSPATH;
staticFiles.precompress = true;
});
Request as cURL:
curl 'http://localhost:4358/asdf.js' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:105.0) Gecko/20100101 Firefox/105.0' -H 'Accept: */*' -H 'Accept-Language: en-US,en;q=0.5' -H 'Accept-Encoding: gzip, deflate, br' -H 'DNT: 1' -H 'Connection: keep-alive' -H 'Referer: http://localhost:4358/' -H 'Sec-Fetch-Dest: script' -H 'Sec-Fetch-Mode: no-cors' -H 'Sec-Fetch-Site: same-origin' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache'
JS data in asdf.js
(the file being mangled):
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[405],{3685:function(e,t,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/",function(){return n(1468)}])},2745:function(e,t,n){"use strict";n.d(t,{DZ:function(){return r},bx:function(){return a},an:function(){return o},i:function(){return c}});var r=["","8:00","9:00","10:00","11:00","12:00","13:00","14:00","15:00","16:00","17:00","18:00","19:00","20:00","21:00"],a={0:"su",1:"mo",2:"tu",3:"we",4:"th",5:"fr",6:"sa"},o={0:"Sunday",1:"Monday",2:"Tuesday",3:"Wednesday",4:"Thursday",5:"Friday",6:"Saturday"},c={NT:"Non-Credit Tisch School of the Arts",GH:"NYU Abu Dhabi - Graduate",CD:"College of Dentistry Continuing Education",DN:"College of Dentistry - Graduate"}},9726:function(e,t,n){"use strict";n.d(t,{L3:function(){return c},vi:function(){return s},wv:function(){return u},bL:function(){return i},sG:function(){return l},mH:function(){return d},SV:function(){return f},MN:function(){return h},oK:function(){return m},uR:function(){return p}});n(4051),n(5893),n(7294),n(4184);var r=n(2745);function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function o(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!==typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,o=[],c=!0,s=!1;try{for(n=n.call(e);!(c=(r=n.next()).done)&&(o.push(r.value),!t||o.length!==t);c=!0);}catch(u){s=!0,a=u}finally{try{c||null==n.return||n.return()}finally{if(s)throw a}}return o}}(e,t)||function(e,t){if(!e)return;if("string"===typeof e)return a(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return a(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e,t){return 0===e?t:"".concat(e," - ").concat(t)}function s(e){if(e.includes("-")&&e.includes("Room")){var t=e.split("-"),n=t[1].split(":");return{Building:t[0],Room:n[1]}}return{Building:e}}function u(e){return"WaitList"===e.status?"Waitlist (".concat(e.waitlistTotal,")"):e.status}function i(e){}function l(e){var t=o(/^(\d{4})-(\d{2})-(\d{2})\s(\d{1,2}):(\d{2}):(\d{2})$/.exec(e),7),n=t[1],r=t[2],a=t[3],c=t[4],s=t[5],u=t[6];return new Date("".concat(n,"-").concat(r,"-").concat(a,"T").concat(("0"+c).slice(-2),":").concat(s,":").concat(u))}function d(e,t){return new Date(e.getTime()+6e4*t)}function f(e,t){return e.getHours()===t.getHours()&&e.getMinutes()===t.getMinutes()&&e.getSeconds()===t.getSeconds()}function h(e){return e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function m(e){var t=e.map((function(e){var t=l(e.beginDate),n=d(t,e.minutesDuration);return{startTime:t,startTimeStr:h(t),day:t.getDay(),endTime:n,endTimeStr:h(n)}})).sort((function(e,t){return e.day-t.day}));if(1===e.length){var n=r.bx[t[0].day].toUpperCase();return"".concat(n," ").concat(t[0].startTimeStr,"-").concat(t[0].endTimeStr)}if(2===e.length){if(f(t[0].startTime,t[1].startTime)){var a=r.bx[t[0].day].toUpperCase(),o=r.bx[t[1].day].toUpperCase();return"".concat(a,",").concat(o," ").concat(t[0].startTimeStr,"-").concat(t[0].endTimeStr)}var c="";return t.forEach((function(e,n){var a=r.bx[e.day].toUpperCase();c+="".concat(a," ").concat(e.startTimeStr,"-").concat(e.endTimeStr),n!==t.length-1&&(c+=". ")})),c}return""}function p(e){var t;return null!==(t=r.i[e])&&void 0!==t?t:""}},1468:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return w}});var r=n(4051),a=n.n(r),o=n(5893),c=n(7294),s=n(3351),u=n(1221),i=n.n(u),l=n(1664),d=n(4184),f=n.n(d),h=n(7123),m=n.n(h);function p(e,t,n,r,a,o,c){try{var s=e[o](c),u=s.value}catch(i){return void n(i)}s.done?t(u):Promise.resolve(u).then(r,a)}function v(e){var t=e.year,n=e.semester,r=(0,c.useState)(""),s=r[0],u=r[1],i=(0,c.useState)({loading:!1,results:[]}),d=i[0],h=i[1],v=function(){var e,r=(e=a().mark((function e(r){return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r.target.value.length>=50)){e.next=3;break}return u(r.target.value.substring(0,50)),e.abrupt("return");case 3:if(u(r.target.value),0!==r.target.value.replace(/\s/g,"").length){e.next=7;break}return h({loading:!1,results:[]}),e.abrupt("return");case 7:h({loading:!0,results:[]}),fetch("https://schedge.a1liu.com/".concat(t,"/").concat(n,"/search?query=").concat(r.target.value.replace(/\s/g,"+"),"&limit=5")).then((function(e){if(e.ok)return e.json();h({loading:!1,results:[]})})).then((function(e){return h({loading:!1,results:e})})).catch((function(e){return console.error(e)}));case 9:case"end":return e.stop()}}),e)})),function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function c(e){p(o,r,a,c,s,"next",e)}function s(e){p(o,r,a,c,s,"throw",e)}c(void 0)}))});return function(e){return r.apply(this,arguments)}}();return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("img",{Loader:!0,className:f()(m().loader,!!d.loading&&m().loading),src:"./loading.svg",alt:"loading symbol"}),(0,o.jsx)("input",{className:m().searchBox,value:s,placeholder:"Search Courses",onChange:v}),(0,o.jsx)("div",{className:m().searchResults,children:0!==s.replace(/\s/g,"").length&&d.results.map((function(e,r){return(0,o.jsx)(l.default,{href:{pathname:"/course",query:"school=".concat(e.subjectCode.school,"&subject=").concat(e.subjectCode.code,"&courseid=").concat(e.deptCourseId,"&year=").concat(t,"&semester=").concat(n)},style:{textDecoration:"none"},children:(0,o.jsxs)("div",{className:m().course,children:[(0,o.jsxs)("span",{className:m().courseSchoolCode,children:[e.subjectCode.school,"-",e.subjectCode.code]}),(0,o.jsx)("span",{className:m().courseId,children:e.deptCourseId}),(0,o.jsx)("span",{className:m().courseName,children:e.name})]})},r)}))})]})}var g=n(7379),y=n(9726);function x(){var e,t,n=(e=["\n padding: 0.25rem 0;\n cursor: pointer;\n\n & > .schoolLink > .schoolTitle {\n font-size: 1.2rem;\n font-family: var(--condensedFont);\n text-align: left;\n margin: 0.2rem 0;\n position: sticky;\n\n & > .schoolCode {\n padding: 0.5rem;\n color: var(--grey600);\n font-weight: 800;\n }\n\n & > .schoolName {\n color: var(--grey900);\n }\n }\n\n &:hover {\n }\n"],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return x=function(){return n},n}function _(e){var t=e.schoolCode,n=e.schoolName,r=e.year,a=e.semester;return(0,o.jsx)(b,{children:(0,o.jsx)(l.default,{className:"schoolLink",href:{pathname:"/school",query:"school=".concat(t,"&year=").concat(r,"&semester=").concat(a)},style:{textDecoration:"none"},children:(0,o.jsxs)("div",{className:"schoolTitle",children:[(0,o.jsx)("span",{className:"schoolCode",children:t}),(0,o.jsx)("span",{className:"schoolName",children:""!==n?n:(0,y.uR)(t)})]})})})}var b=g.ZP.div(x());function j(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function S(e,t,n,r,a,o,c){try{var s=e[o](c),u=s.value}catch(i){return void n(i)}s.done?t(u):Promise.resolve(u).then(r,a)}function N(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function c(e){S(o,r,a,c,s,"next",e)}function s(e){S(o,r,a,c,s,"throw",e)}c(void 0)}))}}function C(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!==typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,o=[],c=!0,s=!1;try{for(n=n.call(e);!(c=(r=n.next()).done)&&(o.push(r.value),!t||o.length!==t);c=!0);}catch(u){s=!0,a=u}finally{try{c||null==n.return||n.return()}finally{if(s)throw a}}return o}}(e,t)||function(e,t){if(!e)return;if("string"===typeof e)return j(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return j(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var w=function(){var e=(0,s.a)(),t=e.year,n=e.semester,r=C(c.useState({loading:!0,data:{}}),2),u=r[0],l=r[1],d=C(c.useState({loading:!0,data:{undergraduate:{},graduate:{},others:{}}}),2),f=d[0],h=d[1];return c.useEffect((function(){N(a().mark((function e(){var t,n;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,fetch("https://schedge.a1liu.com/subjects");case 3:if((t=e.sent).ok){e.next=6;break}return e.abrupt("return");case 6:return e.next=8,t.json();case 8:n=e.sent,l((function(){return{loading:!1,data:n}})),e.next=15;break;case 12:e.prev=12,e.t0=e.catch(0),console.error(e.t0);case 15:case"end":return e.stop()}}),e,null,[[0,12]])})))(),N(a().mark((function e(){var t,n,r,o,c;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,fetch("https://schedge.a1liu.com/schools");case 3:if((t=e.sent).ok){e.next=6;break}return e.abrupt("return");case 6:return e.next=8,t.json();case 8:n=e.sent,r={},o={},c={},Object.keys(n).forEach((function(e){e.startsWith("G")?o[e]=n[e]:e.startsWith("U")||""!==n[e].name?r[e]=n[e]:c[e]=n[e]})),h((function(){return{loading:!1,data:{undergraduate:r,graduate:o,others:c}}})),e.next=17;break;case 14:e.prev=14,e.t0=e.catch(0),console.error(e.t0);case 17:case"end":return e.stop()}}),e,null,[[0,14]])})))()}),[]),(0,o.jsxs)("div",{id:"pageContainer",children:[(0,o.jsx)("div",{className:i().searchContainer,children:(0,o.jsx)(v,{year:t,semester:n})}),(0,o.jsxs)("div",{className:i().schoolsContainer,children:[(0,o.jsx)("div",{id:"departmentTitle",children:"Schools"}),!f.loading&&!u.loading&&(0,o.jsxs)("div",{className:i().schools,children:[(0,o.jsxs)("div",{children:[(0,o.jsx)("div",{className:i().schoolType,children:"Undergraduate"}),Object.keys(f.data.undergraduate).map((function(e,r){return(0,o.jsx)(_,{schoolCode:e,schoolName:f.data.undergraduate[e].name,year:t,semester:n},r)})),Object.keys(f.data.others).map((function(e,r){return(0,o.jsx)(_,{schoolCode:e,schoolName:f.data.others[e].name,year:t,semester:n},r)}))]}),(0,o.jsxs)("div",{children:[(0,o.jsx)("div",{className:i().schoolType,children:"Graduate"}),Object.keys(f.data.graduate).map((function(e,r){return(0,o.jsx)(_,{schoolCode:e,schoolName:f.data.graduate[e].name,year:t,semester:n},r)}))]})]})]})]})}},7123:function(e){e.exports={loader:"SearchBar_loader__Wef_N",loading:"SearchBar_loading__z1SP_",searchBox:"SearchBar_searchBox__BuVsz",searchResults:"SearchBar_searchResults__YBJdk",course:"SearchBar_course__LnfoJ",courseSchoolCode:"SearchBar_courseSchoolCode__USpE5",courseId:"SearchBar_courseId__Nzp42",courseName:"SearchBar_courseName__tZaeA"}},1221:function(e){e.exports={searchContainer:"index_searchContainer__JvuH1",schoolsContainer:"index_schoolsContainer__amMNG",fadeIn:"index_fadeIn__16WFp",schools:"index_schools__vNi1c",deptFadeIn:"index_deptFadeIn__so2KU",schoolType:"index_schoolType__xEIVq"}}},function(e){e.O(0,[513,774,888,179],(function(){return t=3685,e(e.s=t);var t}));var t=e.O();_N_E=t}]);
Additional context
The same asdf.js
file works when precompress
is set to false
.
Other *.js
files seem to work, but all the large ones seem to fail.
Issue Analytics
- State:
- Created a year ago
- Comments:9 (7 by maintainers)
Top Results From Across the Web
Ability to serve individual static files from location other than ...
If the predicate returns true, request is handled by static resource handler, if not, it gives 404. For me it's a perfect option...
Read more >What am I doing wrong with Django static files? - Stack Overflow
One possibility - STATIC_URL won't be filled out in your templates unless you're passing in a RequestContext. Make sure you have something ...
Read more >Serving Static Files - hapi.dev
The inert plugin provides new handler methods for serving static files and directories ... Here, you tell h.file() the path of the image...
Read more >Serving compressed files - Amazon CloudFront
If your origin returns a compressed object to CloudFront, CloudFront detects that the object is compressed based on the presence of a Content-Encoding...
Read more >ASP.NET Core response compression and content encoding
How to use gzip and Brotli compression algorithms in ASP.NET Core to compress output of controller actions and static files.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@vn7n24fzkq I think that is the entire file, it should be one really long line of JS, 11324 bytes long.
@tipsy This one seemed similar: https://github.com/javalin/javalin/issues/1615
Also, I can provide more information if it would be helpful, I’m just unsure what to provide.
The PR that I was implementing when I hit this snag was: https://github.com/A1Liu/schedge/pull/141#discussion_r997726985