Uploaded image for project: 'Dev - Nexus Repo'
  1. Dev - Nexus Repo
  2. NEXUS-10957

ETag 304 causes 404 response through npm proxy group


    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Duplicate
    • Affects Version/s: 3.0.2
    • Fix Version/s: None
    • Component/s: NPM
    • Labels:


      I'm running the latest 3.x in Docker as an npm proxy. I have two repos setup. One is just a proxy of https://registry.npmjs.org. The other is a npm group containing the proxy.

      I found that jspm install npm:string_decoder was failing with a 404 response while npm install string_decoder was working.

      The Nexus request log showed identical requests with one returning 404 and the other 200, so I enabled trace logging and observed that the jspm request was sending an If-None-Match: "3SLQP4XEWUIBONOV855WOPR0B" header while the npm request was not. Here is the full request that was logged:

      2016-09-24 20:31:20,193+0000 DEBUG [qtp2076534592-77]  org.eclipse.jetty.server.Server - REQUEST on HttpChannelOverHttp@4cc991b9{r=1,c=false,a=DISPATCHED,uri=//localhost:8081/repository/npm-group/string_decoder}
      GET //localhost:8081/repository/npm-group/string_decoder
      If-None-Match: "3SLQP4XEWUIBONOV855WOPR0B"
      Host: localhost:8081
      Accept-Encoding: gzip
      Connection: close

      This seems to be the reason for the difference in the response. Further in the log, I see:

      2016-09-24 20:40:09,506+0000 DEBUG [qtp2076534592-216] *UNKNOWN org.sonatype.nexus.repository.view.Router - Response: Response{status=Status{successful=true, code=304, message='null'}, payload=null}
      2016-09-24 20:40:09,506+0000 TRACE [qtp2076534592-216] *UNKNOWN org.sonatype.nexus.repository.view.Router - Response headers:
      2016-09-24 20:40:09,506+0000 TRACE [qtp2076534592-216] *UNKNOWN org.sonatype.nexus.repository.view.Router -   ETag: "3SLQP4XEWUIBONOV855WOPR0B"
      2016-09-24 20:40:09,506+0000 TRACE [qtp2076534592-216] *UNKNOWN org.sonatype.nexus.repository.view.Router - No response attributes
      2016-09-24 20:40:09,506+0000 TRACE [qtp2076534592-216] *UNKNOWN org.sonatype.nexus.common.collect.AttributesMap - Set: success=false (java.lang.Boolean)
      2016-09-24 20:40:09,507+0000 TRACE [qtp2076534592-216] *UNKNOWN org.sonatype.nexus.common.collect.AttributesMap - Set: error=Not found (java.lang.String)

      I found that if I configured my npm registry to reference the proxy repository url directly, that jspm started to work. It was only with the group repository that the ETag 304 response was being turned into a 404. So it appears that something may be broken with how an npm group repository handles ETag headers.

      A workaround is to just target the proxy repository directly or temporarily disable proxying through Nexus. (jspm only seems to have this problem for node core modules; other npm requests came through the group just fine, but presumably w/o etags...no clue why it's requesting core modules at all, but it must have some added local metadata for them that it's using to produce the If-None-Match header for its request.)


          Issue Links



              Unassigned Unassigned
              nlwillia Nathan Williams
              Last Updated By:
              Peter Lynch Peter Lynch
              0 Vote for this issue
              2 Start watching this issue


                Date of First Response: