Skip to content

Commit

Permalink
Added cache: 'no-store' to fetch options (prevent unexpected caching)
Browse files Browse the repository at this point in the history
  • Loading branch information
jawj committed Jul 18, 2023
1 parent 4a69400 commit be367f3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
18 changes: 9 additions & 9 deletions dist/npm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1519,15 +1519,15 @@ B+=A[v],v<P.length&&(B+="$"+(v+1))}P=P.map(v=>(0,Oi.prepareValue)(v));let{fetchE
fetchConnectionCache:te,fetchFunction:be}=me,Z=typeof _=="function"?_(f,m):_,fe=te===
!0?{"Neon-Pool-Opt-In":"true"}:{},re={query:B,params:P};i&&i(re);let z;try{z=await(be??
fetch)(Z,{method:"POST",body:JSON.stringify(re),headers:{"Neon-Connection-String":r,
"Neon-Raw-Text-Output":"true","Neon-Array-Mode":"true",...fe},...ue})}catch(v){let k=new Ze(
`Error connecting to database: ${v.message}`);throw k.sourceError=v,k}if(z.ok){let v=await z.
json(),k=v.fields.map(ie=>ie.name),se=v.fields.map(ie=>$.types.getTypeParser(ie.
dataTypeID)),ne=D===!0?v.rows.map(ie=>ie.map((ce,pe)=>ce===null?null:se[pe](ce))):
v.rows.map(ie=>Object.fromEntries(ie.map((ce,pe)=>[k[pe],ce===null?null:se[pe](ce)])));
return s&&s(re,v,ne,{arrayMode:D,fullResults:V}),V?(v.viaNeonFetch=!0,v.rowAsArray=
D,v.rows=ne,v):ne}else{let{status:v}=z;if(v===400){let{message:k,code:se}=await z.
json(),ne=new Ze(k);throw ne.code=se,ne}else{let k=await z.text();throw new Ze(`\
Database error (HTTP status ${v}): ${k}`)}}}}a(ft,"neon");var Ct=qe(_t());at();var Vs=qe(gt()),$=qe(_t());var En=class En extends Ct.Client{constructor(t){super(t);this.config=t}get neonConfig(){
"Neon-Raw-Text-Output":"true","Neon-Array-Mode":"true",...fe},cache:"no-store",...ue})}catch(v){
let k=new Ze(`Error connecting to database: ${v.message}`);throw k.sourceError=v,
k}if(z.ok){let v=await z.json(),k=v.fields.map(ie=>ie.name),se=v.fields.map(ie=>$.types.
getTypeParser(ie.dataTypeID)),ne=D===!0?v.rows.map(ie=>ie.map((ce,pe)=>ce===null?
null:se[pe](ce))):v.rows.map(ie=>Object.fromEntries(ie.map((ce,pe)=>[k[pe],ce===
null?null:se[pe](ce)])));return s&&s(re,v,ne,{arrayMode:D,fullResults:V}),V?(v.viaNeonFetch=
!0,v.rowAsArray=D,v.rows=ne,v):ne}else{let{status:v}=z;if(v===400){let{message:k,
code:se}=await z.json(),ne=new Ze(k);throw ne.code=se,ne}else{let k=await z.text();
throw new Ze(`Database error (HTTP status ${v}): ${k}`)}}}}a(ft,"neon");var Ct=qe(_t());at();var Vs=qe(gt()),$=qe(_t());var En=class En extends Ct.Client{constructor(t){super(t);this.config=t}get neonConfig(){
return this.connection.stream}connect(t){let{neonConfig:n}=this;n.forceDisablePgSSL&&
(this.ssl=this.connection.ssl=!1),this.ssl&&n.useSecureWebSocket&&console.warn("\
SSL is enabled for both Postgres (e.g. ?sslmode=require in the connection string\
Expand Down
18 changes: 9 additions & 9 deletions dist/serverless.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1999,15 +1999,15 @@ g[_],_<S.length&&(v+="$"+(_+1))}S=S.map(_=>(0,xs.prepareValue)(_));let{fetchEndp
fetchConnectionCache:M,fetchFunction:H}=de,F=typeof E=="function"?E(h,f):E,Y=M===
!0?{"Neon-Pool-Opt-In":"true"}:{},O={query:v,params:S};i&&i(O);let G;try{G=await(H??
fetch)(F,{method:"POST",body:JSON.stringify(O),headers:{"Neon-Connection-String":r,
"Neon-Raw-Text-Output":"true","Neon-Array-Mode":"true",...Y},...T})}catch(_){let P=new gt(
`Error connecting to database: ${_.message}`);throw P.sourceError=_,P}if(G.ok){let _=await G.
json(),P=_.fields.map(N=>N.name),$=_.fields.map(N=>Le.types.getTypeParser(N.dataTypeID)),
D=A===!0?_.rows.map(N=>N.map((j,q)=>j===null?null:$[q](j))):_.rows.map(N=>Object.
fromEntries(N.map((j,q)=>[P[q],j===null?null:$[q](j)])));return s&&s(O,_,D,{arrayMode:A,
fullResults:b}),b?(_.viaNeonFetch=!0,_.rowAsArray=A,_.rows=D,_):D}else{let{status:_}=G;
if(_===400){let{message:P,code:$}=await G.json(),D=new gt(P);throw D.code=$,D}else{
let P=await G.text();throw new gt(`Database error (HTTP status ${_}): ${P}`)}}}}
o(St,"neon");var er=nt(Xt());qt();var Pa=nt(Wt()),Le=nt(Xt());var Ae=class extends er.Client{constructor(t){super(t);this.config=t}static{o(this,
"Neon-Raw-Text-Output":"true","Neon-Array-Mode":"true",...Y},cache:"no-store",...T})}catch(_){
let P=new gt(`Error connecting to database: ${_.message}`);throw P.sourceError=_,
P}if(G.ok){let _=await G.json(),P=_.fields.map(N=>N.name),$=_.fields.map(N=>Le.types.
getTypeParser(N.dataTypeID)),D=A===!0?_.rows.map(N=>N.map((j,q)=>j===null?null:$[q](
j))):_.rows.map(N=>Object.fromEntries(N.map((j,q)=>[P[q],j===null?null:$[q](j)])));
return s&&s(O,_,D,{arrayMode:A,fullResults:b}),b?(_.viaNeonFetch=!0,_.rowAsArray=
A,_.rows=D,_):D}else{let{status:_}=G;if(_===400){let{message:P,code:$}=await G.json(),
D=new gt(P);throw D.code=$,D}else{let P=await G.text();throw new gt(`Database er\
ror (HTTP status ${_}): ${P}`)}}}}o(St,"neon");var er=nt(Xt());qt();var Pa=nt(Wt()),Le=nt(Xt());var Ae=class extends er.Client{constructor(t){super(t);this.config=t}static{o(this,
"NeonClient")}get neonConfig(){return this.connection.stream}connect(t){let{neonConfig:n}=this;
n.forceDisablePgSSL&&(this.ssl=this.connection.ssl=!1),this.ssl&&n.useSecureWebSocket&&
console.warn("SSL is enabled for both Postgres (e.g. ?sslmode=require in the con\
Expand Down
1 change: 1 addition & 0 deletions export/httpQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export function neon(
'Neon-Array-Mode': 'true',
...connCacheHeader,
},
cache: 'no-store',

This comment has been minimized.

Copy link
@nicksrandall
...fetchOptions,
});

Expand Down

0 comments on commit be367f3

Please sign in to comment.