Skip to content

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy

Category: JavaScript

Ajax / JavaScript

Ajax Requests Timeout Only in Production

- 02.01.26 - ErcanOPAK comment on Ajax Requests Timeout Only in Production

Local works, prod fails. WhyReverse proxy timeout limits. Fix Increase server timeout or chunk responses.

Read More
JavaScript

JavaScript Memory Leaks Without Errors

- 02.01.26 - ErcanOPAK comment on JavaScript Memory Leaks Without Errors

Page slows over time. WhyDetached DOM references. Fix Null unused references.

Read More
Ajax / JavaScript

AJAX Requests Work Locally But Fail in Production

- 01.01.26 - ErcanOPAK comment on AJAX Requests Work Locally But Fail in Production

No errors, no data. Why it happensCORS preflight blocked by server config. FixAllow OPTIONS requests explicitly.

Read More
JavaScript

JavaScript forEach Can’t Be awaited

- 01.01.26 - ErcanOPAK comment on JavaScript forEach Can’t Be awaited

Silent async bugs everywhere. Why it happensforEach ignores promises. FixUse for…of or Promise.all.

Read More
Ajax / JavaScript

AJAX — Network Requests Blocked by Mixed Content

- 31.12.25 - ErcanOPAK comment on AJAX — Network Requests Blocked by Mixed Content

HTTPS page calling HTTP endpoint fails silently. Fix Serve everything over HTTPS.

Read More
JavaScript

JavaScript — map() Without Return Creates Undefined Arrays

- 31.12.25 - ErcanOPAK comment on JavaScript — map() Without Return Creates Undefined Arrays

Easy-to-miss bug. Fix Always return explicitly inside map.

Read More
Ajax / JavaScript

AJAX — Browser Caches GET Requests Silently

- 30.12.25 - ErcanOPAK comment on AJAX — Browser Caches GET Requests Silently

Repeated GET calls may not hit the server. ✅ Fix Add cache-busting or proper headers.

Read More
JavaScript

JavaScript — NaN !== NaN Breaks Comparisons

- 30.12.25 - ErcanOPAK comment on JavaScript — NaN !== NaN Breaks Comparisons

NaN is never equal to itself. ✅ Fix Use: Number.isNaN(value)  

Read More
Ajax / JavaScript

AJAX — 204 Responses Break JSON Parsing

- 29.12.25 - ErcanOPAK comment on AJAX — 204 Responses Break JSON Parsing

204 No Content has no body. ❌ Crash response.json() ✅ Fix Check status before parsing.

Read More
JavaScript

JavaScript — Object.freeze() Is Shallow

- 29.12.25 - ErcanOPAK comment on JavaScript — Object.freeze() Is Shallow

Nested objects remain mutable. ✅ Fix Use deep-freeze utilities if immutability matters.

Read More
Ajax / JavaScript

Modern Fetch with Async/Await

- 29.12.25 - ErcanOPAK comment on Modern Fetch with Async/Await

The Problem: You are stuck in “Callback Hell” or complex Promise chains using old XHR or jQuery. The Fix: Use modern fetch inside an async function. It reads like synchronous code. async function getData() { try { const response = await fetch(‘https://api.example.com/data’); const data = await response.json(); console.log(data); } catch (error) { console.error(‘Fetch failed:’, error); […]

Read More
JavaScript

Optional Chaining (?.)

- 29.12.25 - ErcanOPAK comment on Optional Chaining (?.)

The Problem: Your console is full of “Uncaught TypeError: Cannot read property ‘x’ of undefined” because an API response was missing data. The Fix: Use ?. to safely access nested properties. It short-circuits to undefined instead of crashing. // Old risky way const street = user && user.address && user.address.street; // Life-saver way const street […]

Read More
Ajax / JavaScript

AJAX — Missing credentials Breaks Auth Cookies

- 28.12.25 - ErcanOPAK comment on AJAX — Missing credentials Breaks Auth Cookies

fetch(url) ❌ Problem Cookies not sent. ✅ Fix credentials: “include”    

Read More
JavaScript

JavaScript — setInterval Drifts Over Time

- 28.12.25 - ErcanOPAK comment on JavaScript — setInterval Drifts Over Time

Intervals accumulate delay. ❌ Result Timers become inaccurate. ✅ Fix Use recursive setTimeout.

Read More
JavaScript

AJAX — Fetch Does NOT Reject on HTTP Errors

- 27.12.25 - ErcanOPAK comment on AJAX — Fetch Does NOT Reject on HTTP Errors

This surprises many devs. fetch(url) // resolves on 404 ✅ Correct Manually check: if (!response.ok) throw Error();  

Read More
JavaScript

JavaScript — == Can Change Logic After Refactors

- 27.12.25 - ErcanOPAK comment on JavaScript — == Can Change Logic After Refactors

Loose equality causes temporal bugs. if (value == false) ❌ Problem 0, “”, null behave differently over time. ✅ Rule Always use ===.

Read More
Ajax / JavaScript

AJAX — Preflight Requests Are Real Requests

- 25.12.25 - ErcanOPAK comment on AJAX — Preflight Requests Are Real Requests

CORS preflight: Hits server Costs latency Can be blocked ✅ Optimize Avoid unnecessary custom headers.

Read More
JavaScript

JavaScript — JSON.stringify Can Crash on Big Objects

- 25.12.25 - ErcanOPAK comment on JavaScript — JSON.stringify Can Crash on Big Objects

Circular references = runtime error. ✅ Safer Use structured cloning or custom serializers.

Read More
Ajax / JavaScript

AJAX — Network Tab Lies About Timing

- 21.12.25 | 21.12.25 - ErcanOPAK comment on AJAX — Network Tab Lies About Timing

Browser timing includes: DNS SSL Queuing Connection reuse Real insight Use Server-Timing headers for truth.

Read More
JavaScript

JavaScript — structuredClone() Beats JSON Tricks

- 21.12.25 - ErcanOPAK comment on JavaScript — structuredClone() Beats JSON Tricks

Instead of: JSON.parse(JSON.stringify(obj)) Use: structuredClone(obj); Why Preserves Dates, Maps, Sets Faster Safer

Read More
Ajax / JavaScript

Silent JSON Parsing Failures

- 19.12.25 | 19.12.25 - ErcanOPAK comment on Silent JSON Parsing Failures

Backend returns HTML error page → JS crashes silently. ✅ Fix Always check: response.headers.get(“content-type”) Before parsing JSON.

Read More
JavaScript

Microtasks vs Macrotasks — Why setTimeout(0) Lies

- 19.12.25 - ErcanOPAK comment on Microtasks vs Macrotasks — Why setTimeout(0) Lies

Promise.then() // microtask setTimeout() // macrotask 🔥 Reality Microtasks run before repaint. This affects rendering bugs and race conditions.

Read More
Ajax / JavaScript

CORS Errors That Are NOT CORS Errors

- 17.12.25 - ErcanOPAK comment on CORS Errors That Are NOT CORS Errors

Most “CORS issues” are actually: 401 responses Missing headers Redirects ✅ Debug Tip Check Network → Response headers, not console.

Read More
JavaScript

Event Listeners Causing Memory Leaks

- 17.12.25 - ErcanOPAK comment on Event Listeners Causing Memory Leaks

Detached DOM nodes still hold listeners. ❌ Problem element.addEventListener(…) ✅ Fix Remove listeners explicitly or use { once: true }.

Read More
Ajax / JavaScript

AJAX Requests Canceled on Page Navigation

- 17.12.25 - ErcanOPAK comment on AJAX Requests Canceled on Page Navigation

Requests silently stop. 🧠 Reason Browser cancels in-flight requests. ✅ Fix Use navigator.sendBeacon() for critical logs.

Read More
JavaScript

Floating Point Math Is Lying to You

- 17.12.25 - ErcanOPAK comment on Floating Point Math Is Lying to You

0.1 + 0.2 === 0.3 // false ✅ Fix Use rounding: Number((0.1 + 0.2).toFixed(2))  

Read More
Ajax / JavaScript

Silent AJAX Failures — Missing Content-Type

- 16.12.25 - ErcanOPAK comment on Silent AJAX Failures — Missing Content-Type

Backend never hits controller? ✅ Fix headers: { “Content-Type”: “application/json” }  

Read More
JavaScript

forEach + async — A Hidden Logic Bug

- 16.12.25 - ErcanOPAK comment on forEach + async — A Hidden Logic Bug

This does not await: array.forEach(async x => await save(x)); ✅ Fix for (const x of array) { await save(x); }  

Read More
Ajax / JavaScript

AJAX Requests Timeout Randomly — Browser Connection Limits

- 15.12.25 | 15.12.25 - ErcanOPAK comment on AJAX Requests Timeout Randomly — Browser Connection Limits

Browsers limit concurrent connections per domain. ✅ Fix Throttle requests or queue them: await Promise.allSettled(queue.map(run)); Especially important for dashboards batch uploads

Read More
JavaScript

JS “Undefined Is Not Null” — The Bug That Breaks APIs

- 15.12.25 - ErcanOPAK comment on JS “Undefined Is Not Null” — The Bug That Breaks APIs

undefined !== null ✅ Defensive Check if (value == null) { // catches both null and undefined } Use strict checks only when you really need them.

Read More
Page 4 of 6
« Previous 1 2 3 4 5 6 Next »

Posts pagination

« Previous 1 2 3 4 5 6 Next »
June 2026
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  
« May    

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (953)
  • How to add default value for Entity Framework migrations for DateTime and Bool (882)
  • Get the First and Last Word from a String or Sentence in SQL (838)
  • How to select distinct rows in a datatable in C# (808)
  • How to make theater mode the default for Youtube (806)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (580)
  • Add Constraint to SQL Table to ensure email contains @ (580)
  • Average of all values in a column that are not zero in SQL (538)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (506)
  • Find numbers with more than two decimal places in SQL (455)

Recent Posts

  • C#: Use String Interpolation Instead of Concatenation
  • C#: Use Tuples to Return Multiple Values from Methods
  • SQL: Use ISNULL and NULLIF for Smart NULL Handling
  • .NET Core: Use Data Annotations for Model Validation
  • Git: Use Git Clean to Remove Untracked Files
  • Ajax: Add Custom Headers to Fetch Requests
  • JavaScript: Use console.table to Display Arrays as Tables
  • HTML: Use Spellcheck Attribute to Enable Browser Spell Check
  • CSS: Use user-select to Prevent Text Selection
  • Windows 11: Use Snipping Tool for Instant Screenshots

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (953)
  • How to add default value for Entity Framework migrations for DateTime and Bool (882)
  • Get the First and Last Word from a String or Sentence in SQL (838)
  • How to select distinct rows in a datatable in C# (808)
  • How to make theater mode the default for Youtube (806)

Recent Posts

  • C#: Use String Interpolation Instead of Concatenation
  • C#: Use Tuples to Return Multiple Values from Methods
  • SQL: Use ISNULL and NULLIF for Smart NULL Handling
  • .NET Core: Use Data Annotations for Model Validation
  • Git: Use Git Clean to Remove Untracked Files

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com