Skip to content

Importing from npm-check-updates has side effects which causes my program to crash #1524

Open
@Zamiell

Description

@Zamiell

Steps to Reproduce

import { run } from "npm-check-updates";

Having this line in my program causes it to crash with the following output:

app@4d81770b49d3:/app$ bun run ./src/main.ts
413 |  * Unless required by applicable law or agreed to in writing,
414 |  * software distributed under the License is distributed on an "AS
415 |  * IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
416 |  * express or implied. See the License for the specific language
417 |  * governing permissions and limitations under the License.
418 |  */return new n.URL(l.url).hostname!==g.hostname&&(l.headers.delete("authorization"),l.headers.delete("cookie")),(d.status===303||l.method==="POST"&&[301,302].includes(d.status))&&(p.method="GET",p.body=null,l.headers.delete("content-length")),p.headers={},l.headers.forEach((v,w)=>{p.headers[w]=v}),p.counter=++l.counter,{request:new r(n.format(g),p),options:p}},f=async(l,d)=>{const h=a.storable(l,d)?await t(l,d):await s(l,d);if(!["GET","HEAD"].includes(l.method)&&h.status>=200&&h.status<=399&&await t.invalidate(l,d),!c(l,h,d))return h;const p=u(l,h,d);return f(p.request,p.options)};return wf=f,wf}var ib;function JO(){if(ib)return Mr.exports;ib=1;const{FetchError:e,Headers:r,Request:o,Response:n}=An(),a=N8(),t=XO(),s=(c,u)=>{const f=a(u),l=new o(c,f);return t(l,f)};return s.defaults=(c,u={},f=s)=>{typeof c=="object"&&(u=c,c=null);const l=(d,h={})=>{const p=d||c,m={...u,...h,headers:{...u.headers,...h.headers}};return f(p,m)};return l.defaults=(d,h={})=>s.defaults(d,h,l),l},Mr.exports=s,Mr.exports.FetchError=e, | ... truncated

EACCES: permission denied, open '/root/.npmrc'
    path: "/root/.npmrc",
 syscall: "open",
   errno: -13,
    code: "EACCES"

      at Of (/app/node_modules/npm-check-updates/build/index.js:418:20438)
      at g4 (/app/node_modules/npm-check-updates/build/index.js:418:20094)
      at <anonymous> (/app/node_modules/npm-check-updates/build/index.js:418:24523)
      at o (/app/node_modules/npm-check-updates/build/index.js:353:11433)
      at <anonymous> (/app/node_modules/npm-check-updates/build/index.js:418:24653)

Bun v1.2.10 (Linux x64 baseline)

When I comment out the import, then my program proceeds normally.

Expected Behavior

Under no circumstances should there be side-effects from importing a function. This is pure evil. =p

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions